I have a requirement in which on a form button named Track Shipment click I need to call my custom plugin which is implementing FedEx tracking web services (WSDL)
This service takes tracking number as input & get the JSON response.
Now the issue is how can I display that JSON Response on CRM web form?
Or Is there any other why to full fill this requirement?
*This post is locked for comments
I would recommend to use CRMRestBuilder to build your request.
I tried what you suggested.
Now I have registered my Plugin and created on action. Plugin is taking Action as Message.
Now when I am trying to call my Action using javascript Its show me 404.
JavaScript Code
function CallFexExActionPlugin() { var organizationUrl = Xrm.Page.context.getClientUrl(); var query = "wcsti_mailitems(" + Xrm.Page.data.entity.getId().replace('{', '').replace('}', '') + ")/Microsoft.Dynamics.CRM.new_FedEXTracking"; var val = { "TrackingNumber": Xrm.Page.getAttribute("wcsti_trackingnumber").getValue() }; console.log("CallFexExActionPlugin") var data = JSON.stringify(val); $.ajax({ url: organizationUrl + "/api/data/v9.0/" + query, type: 'POST', contentType: "application/json; charset=utf-8", async: false, datatype: "json", data: data, beforeSend: function (XMLHttpRequest) { //Specifying this header ensures that the results will be returned as JSON. XMLHttpRequest.setRequestHeader("Accept", "application/json"); }, success: function (responseText) { console.log(responseText) alert("Action called"); return false; }, error: function (jqXHR, exception) { var msg = ''; if (jqXHR.status === 0) { msg = 'Not connect.\n Verify Network.'; } else if (jqXHR.status == 404) { msg = 'Requested page not found. [404]'; } else if (jqXHR.status == 500) { msg = 'Internal Server Error [500].'; } else if (exception === 'parsererror') { msg = 'Requested JSON parse failed.'; } else if (exception === 'timeout') { msg = 'Time out error.'; } else if (exception === 'abort') { msg = 'Ajax request aborted.'; } else { msg = 'Uncaught Error.\n' + jqXHR.responseText; } console.log(msg); } }); }
Thanks I will try this solution.
Hello,
My recommendation is following:
1. Create an action that has both input and output parameters.
2. Write a plugin that will handle message of this action, get input parameters, call external endpoint, get a response and put your reply JSon to output parameter of action.
3. Call this action using JavaScript and WebApi and use response that you got from endpoint.
Good luck!
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156