Saltar al contenido principal
Adaptive Planning
Última actualización: 2023-06-23
getIntacctSessionID

getIntacctSessionID

Un desarrollador de JavaScript debe modificar esta secuencia de comandos de inicio de CCDS para su caso de uso. No funcionará sin modificaciones.
Guarde el siguiente bloque de código como secuencia de comandos en su SAGE Intacct CCDS y asígnele el nombre 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; } }