【问题标题】:CRM custom activity do not return output argumentCRM 自定义活动不返回输出参数
【发布时间】:2021-06-10 05:40:56
【问题描述】:

我已经编写了如下自定义活动,

namespace Tu.Crm.Packages.WorkFlows
{
    public sealed class VersionFinder : CodeActivity
    {
        [Output("VersionDate")]
        public OutArgument<string> VersionDate { get; set; }

        protected override void Execute(CodeActivityContext executionContext)
        {
            IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();
           
            try
            {
                IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
                IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);
                VersionDate.Set(executionContext, "1#22/01/2019");
                
            }
            catch (FaultException<OrganizationServiceFault> e)
            {
                // Handle the exception.
                throw new InvalidPluginExecutionException("Some error occurred/Proxy service unreachable" + e.StackTrace);
            }
        }
    }
}

我正在尝试从 JavaScript 调用此活动。

var req = new XMLHttpRequest();
req.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/new_versionfinderc2dcf0b12782eb11814500155de400c4", false);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.onreadystatechange = function() {
    if (this.readyState === 4) {
        req.onreadystatechange = null;
        if (this.status === 204) {
            Xrm.Utility.alertDialog(this.ResponseXML);
        } else {
            Xrm.Utility.alertDialog(this.ResponseXML);
        }
    }
};
req.send();

但是,它没有返回任何数据。有什么问题?

【问题讨论】:

  • 任何后续问题?

标签: javascript dynamics-crm custom-action dynamics-crm-webapi custom-activity


【解决方案1】:

我从未尝试过使用 web api 直接在 js 中调用自定义工作流活动,而且通常不做 AFAIK。推荐的方式是将其转换为custom action,并在js web api中调用。

如果您想保留此 CWA,请在 UI 工作流程中使用它并从 js web api 执行 WF。您也可以在自定义操作中使用 CWA。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-14
    • 1970-01-01
    • 2022-09-20
    相关资源
    最近更新 更多