getIntacctSessionID
この CCDS スターター スクリプトは、JavaScript 開発者がユース ケースに合わせて変更する必要があります。変更しないと機能しません。
以下のコード ブロックを SAGE Intacct CCDS にスクリプトとして保存し、「getIntacctSessionID」という名前を付けます。
function getIntacctSessionID(intacctURL,intacctRequestParms) { //get a session id to use for subsequent api calls var xmlSessionIDRequest = '<?xml version="1.0" encoding="iso-8859-1"?><request><control><senderid>' + intacctRequestParms.senderId +'</senderid>' + '<password>' + intacctRequestParms.senderPassword + '</password><controlid>' + intacctRequestParms.control_controlid +'</controlid><uniqueid>' + intacctRequestParms.control_uniqueid + '</uniqueid>' + '<dtdversion>' + intacctRequestParms.control_dtdversion + '</dtdversion></control>' + '<operation> <authentication>' + '<login><userid>' + intacctRequestParms.userID + '</userid><companyid>' + intacctRequestParms.companyId + '</companyid><password>' + intacctRequestParms.userPassword + '</password>'; //clientId and locationId are optional if (intacctRequestParms.clientId !== null && intacctRequestParms.clientId.trim() !== '' ) xmlSessionIDRequest += '<clientid>' + intacctRequestParms.clientId + '</clientid>'; if (intacctRequestParms.locationId !== null && intacctRequestParms.locationId.trim() !== '' ) xmlSessionIDRequest += '<locationid>' + intacctRequestParms.locationId + '</locationid>'; xmlSessionIDRequest += '</login></authentication>' + '<content><function controlid="' + intacctRequestParms.control_controlid + 'XXX"><getAPISession/></function></content></operation></request>'; //send XML request and get response var xmlSessionIDResponse = sendAndGetXML_Intacct(intacctURL,xmlSessionIDRequest); if (xmlSessionIDResponse ) { //we've already checked for success so now need to extract the session id //note, this uses the older xml parser. This parser works fine with smaller payloads but is not recommended for larger ones var parser = ai.xml.createParser(); var xmlDoc = parser.parse(xmlSessionIDResponse.toString()); var apiEl = xmlDoc.getRootElement().getChildElement('operation').getChildElement('result').getChildElement('data').getChildElement('api'); var sessionid = apiEl.getChildElement('sessionid').getText(); var endpoint = apiEl.getChildElement('endpoint').getText(); //var location = apiEl.getChildElement('locationid').getText(); return {'sessionId': sessionid, 'endpoint': endpoint}; } else { //session id not found return false; } }