Setting screen properties within a multiblock ASP page using the COM API

Less than one minute read time.

This COM API trick for ASP based Application Extensions shows how you can create a screen with 2 (or more) blocks where one of the blocks remains in view mode regardless of the value of CRM.Mode.

It is a very simple approach and all you have to do is get hold of the block that you wish to be read only and then roll through its fields setting them to be readonly. The tip relies on the screen or entrygroup block being an enumerable object.


var OppoRecordId = CRM.GetContextInfo("opportunity","oppo_opportunityid");

var OppoRecord = CRM.FindRecord("opportunity","oppo_opportunityid="+intRecordId);
var OppoWebPickerBlock = CRM.GetBlock("OpportunityWebPicker");
var OppoDetailBoxBlock = CRM.GetBlock("OpportunityDetailBox");

var myBlockContainer = CRM.GetBlock("Container");
with (myBlockContainer)
{
AddBlock(OppoWebPickerBlock);
AddBlock(OppoDetailBoxBlock);
}

OppoWebPickerBlock.ArgObj = OppoRecord;
OppoDetailBoxBlock.ArgObj = OppoRecord;

//Set EntryBlock properties for an EntryGroup Block using an Enumerator
var myE = new Enumerator(myBlock);
while (!myE.atEnd())
{
myEntryBlock = myE.item();
myEntryBlock.ReadOnly = false;
myEntryBlock.Required = false;

myE.moveNext();
}

CRM.AddContent(myBlockContainer.Execute());
Response.Write(CRM.GetPage());

Parents
  • Hi Jeff;

    When I use this method to add a new record, that is,

    SpeakingRecord = CRM.CreateRecord("SpeakingRequest");

    when I save the result I got an error:

    fselectsql,time,sql,errormsg 0 select * from SpeakingRequest WITH (NOLOCK) where spkreq_speakingID= AND spkreq_Deleted is null Incorrect syntax near the keyword 'AND'

    How do I solve it?

    Thanks.

Comment
  • Hi Jeff;

    When I use this method to add a new record, that is,

    SpeakingRecord = CRM.CreateRecord("SpeakingRequest");

    when I save the result I got an error:

    fselectsql,time,sql,errormsg 0 select * from SpeakingRequest WITH (NOLOCK) where spkreq_speakingID= AND spkreq_Deleted is null Incorrect syntax near the keyword 'AND'

    How do I solve it?

    Thanks.

Children
No Data