Today, let's look at Bound/unbound custom action, what is custom action? The unknown partners are out, and Dynamics CRM 2013 has this feature. Like WhoAmI, we can call them through code, but today I'm going to tell you how to invoke them using the Web API.
Custom action is also divided into bound and unbound two types, their specific meaning and function and action before the difference, the only difference is that the custom action here is our own configuration, here in popular science, We can create an action in the setting-process, which creates the following interface:
Bound Custom Action
Unbound Custom Action
They are called in the same way as the OOB action, without distinction, as the following code snippet can be consulted:
Bound Custom Action
Httprequestmessage custboundactionreq = new Httprequestmessage (httpmethod.post, Webapiurl + "/accounts ( 723EF58A-75BB-E511-80D9-C4346BC43F3C)/microsoft.dynamics.crm.new_createprimarycontactforaccount "); CustBoundActionReq.Headers.Authorization = new Authenticationheadervalue ("Bearer", auth. Acquiretoken (). Accesstoken); Jobject custboundactioncontent = new Jobject (); Custboundactioncontent.add ("FirstName", "Jeff"); Custboundactioncontent.add ("LastName", "Xiong"); Custboundactioncontent.add ("Telephone", "15000303158"); Custboundactioncontent.add ("Email", "[email protected]"); Custboundactionreq.content = new Stringcontent (Jsonconvert.serializeobject (custboundactioncontent), Encoding.UTF8, "Application/json"); Httpresponsemessage Custboundactionresp = await client. SendAsync (Custboundactionreq); if (custboundactionresp.issuccessstatuscode) {jobject result =Jsonconvert.deserializeobject<jobject> (await CustBoundActionResp.Content.ReadAsStringAsync ()); Console.WriteLine (result); }
Unbound Custom Action
Httprequestmessage custactionreq = new Httprequestmessage (httpmethod.post, Webapiurl + "/new_createdemoaccount_ua"); "Accounts (723ef58a-75bb-e511-80d9-c4346bc43f3c)/microsoft.dynamics.crm.new_createdemoaccount" CustActionReq.H Eaders. Authorization = new Authenticationheadervalue ("Bearer", auth. Acquiretoken (). Accesstoken); Jobject custactioncontent = new Jobject (); Custactioncontent.add ("AccountName", "Jeff ' s Demo account"); Custactionreq.content = new Stringcontent (Jsonconvert.serializeobject (custactioncontent), Encoding.UTF8, " Application/json "); Httpresponsemessage Custactionresp = await client. SendAsync (Custactionreq); if (custactionresp.issuccessstatuscode) {jobject result = Jsonconvert.deserializeobject<jobj Ect> (await CustActionResp.Content.ReadAsStringAsync ()); Console.WriteLine (result); }
isn't it easy? The small partners need to know that before we define such a custom action we have to spend Dickens, Daoteng Web service or something. Now we just need to through the UI interface can easily configure a good action, is not very happy!
Dynamics CRM 2015/2016 Web api:unbound Custom action and Bound custom action