【问题标题】:Sage CRM - Loading a screen with a entity data?Sage CRM - 加载带有实体数据的屏幕?
【发布时间】:2016-09-15 14:05:37
【问题描述】:

鉴于此代码:

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???编辑时我相信是哪个?

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

【问题讨论】:

    标签: sage-crm


    【解决方案1】:

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

    首先,您需要获取 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);
    

    但是,我们建议您进行更多的错误/异常处理。如果用户正在保存记录,您还需要在页面写入后添加重定向。

    六点支持

    【讨论】:

    • 很好,但是当我尝试保存更改时,它在第 21 行出现错误:eWare.eWareBlockContainer error '8000ffff' [SafeCall Exception]: Error de SQL。第 21 行是CRM.AddContent(Container.Execute());
    • SQL 日志是怎么说的?
    • 暂时未捕获。但我设法这样做:当屏幕处于编辑模式时,我只需使用 CRM.GetPageNoFrameSet() 等打印所有 Sage CRM 页面。现在当我点击保存按钮时(我猜该操作设置为非常相同的页面)Request.Form 已定义,因此屏幕处于保存模式,然后才出现我 SaveChanges() 并关闭弹出窗口,重新加载父开瓶器 wuindow 等(全部不打印任何内容)。因为篇幅太小,这里就不放所有代码了
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-24
    • 1970-01-01
    • 2017-02-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多