Could someone help me please regarding my code below. I'm using Dynamics 365 v9.1 wave 2
I have a refreshForm function which im trying to trigger on a successful response via a POST call, however using the old method of xrm.page it works fine, however im trying future proof, however I can't get it to work using the new formContext method.
function refreshForm(executionContext){ formContext = executionContext.getFormContext(); //Xrm.Page.data.refresh(true); formContext.data.refresh(); } function callFlow(primaryControl){ var formContext = primaryControl; var returnGUID = formContext.data.entity.getId(); var returnGUID = returnGUID.replace('{', '').replace('}', ''); if (typeof ($) === 'undefined') { $ = parent.$; jQuery = parent.jQuery; } var settings = { "async": true, "crossDomain": true, "url": "https://*******************************", "method": "POST", "headers": { "Content-Type": "application/json", "cache-control": "no-cache", "Postman-Token": "*****************************" }, "processData": false, "data": "{\n \"returnid\": \"(" returnGUID ")\"\n}", "success": function () {console.log("Connection Successful");} } $.ajax(settings).done(function (response) { console.log(response); if (response.StatusCode == "SUC-999") { alert("Return Submission Successful"); refreshForm(); } else { alert("There has been an error. \n Error code and description:" response.StatusCode " - " response.StatusDescription); } }); }
Hello,
Try to use following code:
function refreshForm(executionContext){ formContext = executionContext.getFormContext(); //Xrm.Page.data.refresh(true); formContext.data.refresh(); } function callFlow(primaryControl){ var formContext = primaryControl; var returnGUID = formContext.data.entity.getId(); var returnGUID = returnGUID.replace('{', '').replace('}', ''); if (typeof ($) === 'undefined') { $ = parent.$; jQuery = parent.jQuery; } var settings = { "async": true, "crossDomain": true, "url": "******", "method": "POST", "headers": { "Content-Type": "application/json", "cache-control": "no-cache", "Postman-Token": "****" }, "processData": false, "data": "{\n \"returnid\": \"(" returnGUID ")\"\n}", "success": function () {console.log("Connection Successful");} } $.ajax(settings).done(function (response) { console.log(response); if (response.StatusCode == "SUC-999") { alert("Return Submission Successful"); formContext.data.refresh(); } else { alert("There has been an error. \n Error code and description:" response.StatusCode " - " response.StatusDescription); } }); }
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