sendAndGetXML_Intacct
Lo script iniziale di CCDS deve essere modificato da uno sviluppatore javaScript per il caso d'uso. Non funzionerà senza modifiche.
Salvare il blocco di codice seguente come script nel CCDS SAGE Intacct e denominarlo sendAndGetXML_Intacct.
function sendAndGetXML_Intacct(intacctURL,strXMLRequest) { //Make the request to Intacct and look for errors in the result //The actual request is in strXMLRequest in fully formed XML //If no errors found then return the body of the response to the caller, otherwise return false. //The caller is responsible for checking the response and parsing out the payload. //Create a https request to send to Intacct API var url = intacctURL; var method = 'POST'; var body = strXMLRequest; var headers = { 'Content-Type': 'x-intacct-xml-request' }; var response, responseBody; //Send request and receive response try { response = ai.https.request(url, method, body, headers); } catch(e) { //catastrophic failure ai.log.logError('Intacct Request Failed','Intacct request failed. Error: ' + e + ' req: ' + body); return false; } //verify a good http return code var httpCode = response.getHttpCode(); if (httpCode != '200') { ai.log.logError('Intacct Request Failed','Intacct request failed. Http response code: ' + httpCode); return false; } return response.getBody(); }