Hi Dynamics community,
I've been tasked with doing some JavaScript development for a customer and I've run into a bit of a wall - I was hoping if I could get some assistance. The customer would like a web request to be pushed out when a Case object is created, and for another, different request to be pushed when a Case is closed. However, I've been running into an error or two and was hoping if I could get some more eyes on my code. At the moment, most of it is commented out, as I'm just testing the triggers, but I'm getting the error Required parameter is null or undefined: handler on load, even with this stripped-down code.
Currently, I have the onSave and onLoad functions tied to their respective triggers.
As for why this isn't a Workflow triggering On/After create, there's no way I could find to access a web resource / run JavaScript based on said Workflow - meaning we couldn't push a web request this way; if there is a way to do this, please let me know!
function caseOnLoad(){ alert("On Load Change Handler Added"); Xrm.Page.getAttribute("createdon").addOnChange(openCase()); } function caseOnSave(){ alert("On Save"); if(Xrm.page.getAttribute("statecode") == "Resolved" || Xrm.page.getAttribute("statecode") == "Cancelled"){ closeCase(); } return; } function openCase(){ alert("Open Case"); /*var myHeaders = new Headers(); myHeaders.append("Content-Type", "application/xml"); myHeaders.append("Accept", "application/xml"); myHeaders.append("Authorization", "XXXXXXXXXXXXXXXXXXXX"); var raw = '\r\n' '\r\n' '' Xrm.page.getAttribute("customerid").getValue() '\r\n' '' Xrm.page.getAttribute("new_invoicenumber").getValue() '\r\n' '' Xrm.page.getAttribute("ticketnumber").getValue() '\r\n' '' Xrm.page.getAttribute("createdon").getValue() '\r\n' '' TEST USER '\r\n ' ''; var requestOptions = { method: 'POST', headers: myHeaders, body: raw, redirect: 'follow' }; fetch("XXXXXXXXXXXXXXXXXXXX", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error));*/ return; } function closeCase(){ alert("Close Case"); /*var myHeaders = new Headers(); myHeaders.append("Content-Type", "application/xml"); myHeaders.append("Accept", "application/xml"); myHeaders.append("Authorization", "XXXXXXXXXXXXXXXXXXXX"); var raw = '\r\n' '\r\n' '' Xrm.page.getAttribute("customerid").getValue() '\r\n' '' Xrm.page.getAttribute("new_invoicenumber").getValue() '\r\n' '' Xrm.page.getAttribute("ticketnumber").getValue() '\r\n' ''; var requestOptions = { method: 'POST', headers: myHeaders, body: raw, redirect: 'follow' }; fetch("XXXXXXXXXXXXXXXXXXXX", requestOptions) .then(response => response.text()) .then(result => console.log(result)) .catch(error => console.log('error', error));*/ return; }
DAnny3211
126
Daniyal Khaleel
117
Abhilash Warrier
70
Super User 2025 Season 2