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;

    My bad I did not explained very well.

    I wrote several ASP files to do my work.

    I have a New record screen which contains one block, everything works fine.

    I also wrote a edit screen which divide a record into three blocks so it looks better, which also works fine.

    Then I try to merge these two ASP pages into one page.

    if ( intSpeakingID == 0 )

    SpeakingRecord = CRM.CreateRecord("SpeakingRequest");

    else

    SpeakingRecord = CRM.FindRecord("SpeakingRequest","spkreq_speakingID=" + intSpeakingID);

    for edit an existed record, it still works. But for a new record I got this error.

    Regards!

Comment
  • Hi Jeff;

    My bad I did not explained very well.

    I wrote several ASP files to do my work.

    I have a New record screen which contains one block, everything works fine.

    I also wrote a edit screen which divide a record into three blocks so it looks better, which also works fine.

    Then I try to merge these two ASP pages into one page.

    if ( intSpeakingID == 0 )

    SpeakingRecord = CRM.CreateRecord("SpeakingRequest");

    else

    SpeakingRecord = CRM.FindRecord("SpeakingRequest","spkreq_speakingID=" + intSpeakingID);

    for edit an existed record, it still works. But for a new record I got this error.

    Regards!

Children
No Data