Sage CRM - 加载带有实体数据的屏幕?

Sage CRM - Loading a screen with a entity data?

鉴于此代码:

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???我认为是在编辑时?

如何实现用实体数据填充屏幕的字段? 在这种情况下它是一个通信实体

为了用数据填充自定义屏幕,您需要将数据传递到屏幕。

首先,您需要获取Id值。在这种情况下,我们从 URL:

获取它
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(","));
}

某些用户操作可以使 URL 在同一属性中包含多个 ID。在这些情况下,这些 ID 以逗号分隔。因此,如果未定义 Id,我们会检查其中是否有逗号。如果有,我们取第一个ID。

有了Id之后,我们需要加载记录。在这一点上,您应该已经检查过您有一个有效的 ID(例如不为零)并进行一些错误处理。在某些页面中您可能想要显示错误,在其他页面中您可能想要创建一个新的空白记录。这得到记录:

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

之后,您需要将记录应用到屏幕上。使用上面的示例:

CustomCommunicationDetailBox.ArgObj = CommRecord;

将所有这些添加到您的脚本中,您将得到:

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);

但是,我们建议加入更多 error/exception 处理。如果用户正在保存记录,则还需要在页面写入后添加重定向。

六点支持