简体   繁体   English

如何使用 Dynamics 365 的保存和路由按钮?

[英]How can I work with save and route button Dynamics 365?

I need to validate if some notes exist in Dynamics 365 before saving and assign (route), the problem is that fetch goes async and save goes sync... I know that by now Microsft recommends going async, so what's the viable solution to do?我需要在保存和分配(路由)之前验证 Dynamics 365 中是否存在一些注释,问题是 fetch 会异步,save 会同步……我知道现在 Microsft 建议使用异步,那么可行的解决方案是什么? Save can be canceled and called, but how can I cancel and call the button save and route?可以取消和调用保存,但是如何取消和调用按钮保存和路由? or something similar to do this async?或类似的东西做这个异步?

I have tried a lot of similar things, but it doesn't work.我尝试了很多类似的东西,但它不起作用。

Is there some AddChange to Notes(linked to Entity)?是否有一些 AddChange 到 Notes(链接到实体)?

Typically we will cancel the Save event using preventDefault() , complete the required steps & reissue the Save like discussed here .通常,我们将使用preventDefault()取消Save事件,完成所需的步骤并重新发出Save ,如此处讨论的那样

In your scenario, special Save & Route button is achieving Save as well as Apply Routing Rule action.在您的场景中,特殊的Save & Route按钮实现了Save & Route Apply Routing Rule操作。 There's no save mode for this sequence to use getSaveMode for intercepting & reissue.此序列没有使用getSaveMode进行拦截和重新发布的保存模式。 Reference 参考

But you can try a custom Save & Route button using Ribbon workbench and invoke a custom Javascript action to do:但是您可以使用功能区工作台尝试自定义保存和路由按钮并调用自定义 Javascript 操作来执行以下操作:

  1. Validate your Notes record check using fetchXML/web api使用 fetchXML/web api 验证您的Notes记录检查
  2. Save the record保存记录
  3. Call the ApplyRoutingRule action using webapi Read more使用 webapi 调用ApplyRoutingRule操作阅读更多

Don't forget that Xrm.WebApi is always Asynchronous, you have to do chain of calls inside success callback or use XMLHttpRequest for synchronous mode.不要忘记Xrm.WebApi始终是异步的,您必须在成功回调中执行调用链或使用XMLHttpRequest进行同步模式。 Read more 阅读更多

Update : I composed this snippet with the help of CRM REST Builder, try it.更新:我在 CRM REST Builder 的帮助下编写了这个片段,试试吧。

var parameters = {};
var target = {};
target.incidentid = "00000000-0000-0000-0000-000000000000"; 
target["@odata.type"] = "Microsoft.Dynamics.CRM.incident";
parameters.Target = target;

var applyRoutingRuleRequest = {
    Target: parameters.Target,

    getMetadata: function() {
        return {
            boundParameter: null,
            parameterTypes: {
                "Target": {
                    "typeName": "mscrm.crmbaseentity",
                    "structuralProperty": 5
                }
            },
            operationType: 0,
            operationName: "ApplyRoutingRule"
        };
    }
};

Xrm.WebApi.online.execute(applyRoutingRuleRequest).then(
    function success(result) {
        if (result.ok) {
            //Success - No Return Data - Do Something
        }
    },
    function(error) {
        Xrm.Utility.alertDialog(error.message);
    }
);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何防止表单在 Dynamics 365 中保存 - How can I prevent a form from saving in Dynamics 365 如何通过 javascript 单击 Dynamics 365 功能区按钮 - How to click Dynamics 365 Ribbon Button via javascript 如何在 Dynamics 365 on-premises 的日期时间字段中限制最小和最大小时数? - How can I restrict minimum and maximum hours in a datetime field in Dynamics 365 on-premise? 如何在Microsoft dynamics crm 365中通过javascript获取查找字段的值 - How can I get the value of a lookup field by javascript in Microsoft dynamics crm 365 如何在 MS Dynamics 365 中自动填写表单? - How do I automate form filling in MS Dynamics 365? 将 email 上的“至”字段设置为动态 365 - Set "to" field on email form i dynamics 365 当在Dynamics 365中使用JavaScript单击“完成”按钮时,如何将约会标记为“完成” - How to mark an appointment as “completed” when the “finished” button is clicked using JavaScript in dynamics 365 如何通过单击按钮保存 cookie? - How can I save a cookie with the click of a button? 如何在 Dynamics CRM 365 中插入潜在客户数据? - How to insert lead data in Dynamics CRM 365? javascript Dynamics 365无法在刷新前保存我的字段 - javascript Dynamics 365 unable to save my field before refreshing
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM