Hi Guys I am getting XML response but whenever I a...
# suitescript
n
Hi Guys I am getting XML response but whenever I am parsing it says : org.mozilla.javascript.EcmaError: TypeError: Cannot call method "fromString" of undefined (/SuiteScripts/) Below is the XML and code : <?xml version="1.0" encoding="UTF-8"?> <soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <LaunchEventResponse xmlns="http://Eprise"> <LaunchEventResult> <ErrorString>No Error</ErrorString> <ErrorNum>1</ErrorNum> <Data><![CDATA[<LaunchEventResults><Note>1 events launched</Note><LaunchedEvents><LaunchedEvent><ForWhomEmployee><Guid>383f5305-4802-4b18-8301fb85fbd38c76</Guid><Employee_HRISID>112020</Employee_HRISID><SSOAuthParam>mah</SSOAuthParam><LoginID></LoginID><Email>mah@gmail.com</Email><LifeSuiteID></LifeSuiteID><FirstName>Mahesh</FirstName><LastName>Alavala</LastName><MiddleName></MiddleName><MiddleInitial></MiddleInitial></ForWhomEmployee><Name>Onboarding</Name><EventID>1186</EventID><EventStatus>Active</EventStatus><CreationDate>2020-12-04T025134</CreationDate><EffectiveDate>2020-11-12</EffectiveDate><Categories><Base_Location> Sapphire</Base_Location><Employee_Type>Employee</Employee_Type><H1B_Transfer>No</H1B_Transfer><Legal_Employer>Technologies Private Limited</Legal_Employer><Level>7</Level><Relocation>No</Relocation><All_Roles>Senior Engineer</All_Roles><Practice>Information Systems</Practice><Location_City_State>Bangalore</Location_City_State><Employee_Function>GDM</Employee_Function><All_Business_Unit>echnologies India BU</All_Business_Unit><Hire_Type>Lateral</Hire_Type><Department>IS Operations</Department><Client>CICO-01 </Client><Candidate_Type>Employee</Candidate_Type></Categories></LaunchedEvent></LaunchedEvents><Note>0 events not launched</Note><Note>Parsing started at Friday, December 04, 2020 62459 AM and ended at Friday, December 04, 2020 62501 AM</Note></LaunchEventResults>]]></Data> </LaunchEventResult> </LaunchEventResponse> </soap:Body> </soap:Envelope> var xmlDocument = xml.Parser.fromString({ text: sssss }); var Error= xmlDocument.getElementsByTagName({ tagName: 'ErrorNum' })[0].textContent;
b
how are you loading N/xml
n
in 2.0 i added
define(["N/record","N/search",'N/https','N/xml','N/format', 'N/cache'], function (record,search,https,xml,format,cache) {
b
that looks like the proper way to load your xml
probably have to share more code, ill be looking for things like overwriting the xml variable
that said, your xml string is likely to confuse the parser from N/xml
it does not do well with CDATA