0

鉴于此代码:

var Container = CRM.GetBlock("Container");
    var CustomCommunicationDetailBox = CRM.GetBlock("CustomCommunicationDetailBox");
    Container.AddBlock(CustomCommunicationDetailBox);

    if(!Defined(Request.Form)){
        CRM.Mode=Edit;
    }else{
            CRM.Mode=Save;
        }

    CRM.AddContent(Container.Execute());
    var sHTML=CRM.GetPageNoFrameset();
    Response.Write(sHTML);

我用这个参数调用这个.asp页面,但似乎不起作用

popupscreeens.asp?SID=33185868154102&Key0=1&Key1=68&Key2=82&J=syncromurano%2Ftabs%2FCompany%2FCalendarioCitas%2Fcalendariocitas.asp&T=Company&Capt=Calendario%2Bcitas&CLk=T&PopupWin=Y&Key6=1443Act=512

注意 Key6=Comm_Id 和 Act=512??? 我相信它是在编辑时?

我怎样才能用实体达达填充屏幕的字段?在这种情况下,它是一个通信实体

4

1 回答 1

1

In order to populate a custom screen with data, you need to pass the data to the screen.

First, you need to get the Id value. In this case, we're getting it from the URL:

var CommId = Request.QueryString("Key6") + '';

We're going to put a few other checks in though. These are mainly to handle scenarios that have come up in different versions or from different user actions.

// check we have a value and get the Id from context if we don't
if(CommId == 'undefined'){
    CommId = CRM.GetContextInfo("Communication","comm_communicationid");
}
// if CommId is still undefined, set it to zero to check later
// otherwise, make sure the URL only contains one CommId
if(CommId == 'undefined'){
    CommId = 0;
} else if(CommId.indexOf(",") > -1){
    CommId = CommId.substr(0,CommId.indexOf(","));
}

Certain user actions can make the URL hold multiple Ids in the same attribute. In these cases, those Ids are separated by commas. So, if the Id is not defined, we check if there is a comma in it. If there is, we take the 1st Id.

After we have the Id, we need to load the record. At this point, you should have already checked you have a valid id (E.g. not zero) and put some error handling in. In some pages you may want to display an error, in others you may want to create a new, blank record. This gets the record:

var CommRecord = CRM.FindRecord("communication","comm_communicationid = " + CommId);

After that, you need to apply the record to the screen. Using your example above:

CustomCommunicationDetailBox.ArgObj = CommRecord;

Adding all that to your script, you get:

var CommId = Request.QueryString("Key6") + '';

// check we have a value and get the Id from context if we don't
if(CommId == 'undefined'){
    CommId = CRM.GetContextInfo("Communication","comm_communicationid");
}

// if CommId is still undefined, set it to zero to check later
// otherwise, make sure the URL only contains one CommId
if(CommId == 'undefined'){
    CommId = 0;
} else if(CommId.indexOf(",") > -1){
    CommId = CommId.substr(0,CommId.indexOf(","));
}

// add some error checking here

// get the communication record
var CommRecord = CRM.FindRecord("communication","comm_communicationid = " + CommId);

// get the container and the detail box
var Container = CRM.GetBlock("Container");
var CustomCommunicationDetailBox = CRM.GetBlock("CustomCommunicationDetailBox");

// apply the communication record to the detail box
CustomCommunicationDetailBox.ArgObj = CommRecord;

// add the box to the container
Container.AddBlock(CustomCommunicationDetailBox);

// set the moder
if(!Defined(Request.Form)){
    CRM.Mode=Edit;
} else {
    CRM.Mode=Save;
}

// output
CRM.AddContent(Container.Execute());
var sHTML=CRM.GetPageNoFrameset();
Response.Write(sHTML);

However, we would advise putting in more error/exception handling. If the user is saving the record, you will also need to add a redirect in after the page is written.

Six Ticks Support

于 2016-09-16T08:38:07.017 回答