Web Service Methods
19 min
this section lists the web service methods that you can use these methods are based on javascript strongly recommends using the secure protocol https instead of http within the platform to ensure data security and integrity about using web service methods with quick action scripts and external business object scripts the following web service methods are supported in quick action scripts getwebservicefromurl getwebservice executequickaction create get search executewebrequest htmlencode htmldecode hextobytes bytestostring loadxml getcultureinfo gettimezoneinfo hash keyedhash the following web service methods are supported in external business object scripts getwebservicefromurl getwebservice setreturndata setreturndataforcondition get search executewebrequest synchronizeallheatdata synchronizeallheatdatawithrelated synchronizeheatdata synchronizeheatdatawithrelated htmlencode htmldecode hextobytes bytestostring loadxml getcultureinfo gettimezoneinfo hash keyedhash about the heatcontext variable variable heatcontext description this context variable is available in the setreturndata and synchronization scripts this object contains information about the reason why the script is executed parameters locale contains the locale identifier such as 'en us' if the script is invoked as a result of user action then it contains the locale associated with the user session tenantid tenant identifier businessobject information about the business object that the script is associated with uibusinessobject if the script is associated with a validation list business object, then when the pick list for that validation list business object is used in the workspace, it contains the business object associated with the workspace for example, if the pick list is referenced in the incident workspace, it contains information about the incident business object picklist if the script is invoked to fetch values for a pick list, this contains the details of the pick list if the pick list is a validation provider pick list and used in the service catalog, then the arguments below contain validation parameters name and their values arguments when the script is invoked to fetch the latest data from external sources, it has the following information list contains an object that holds the following information fieldfilter if any filter is defined in the list workspace by the user definitionname name of the list that caused the invocation of this script searchinfo if the list uses a saved search to populate the data, this contains the search criteria that is defined in that construct dependentinfo if the list is part of a dependent child tab, this contains information about the relationship between the parent business object and other information examples are masterobjecttableref, masterobjectid, relationshiptag, and dependentrel2name when the script is invoked from another script using executescript(), it contains the value passed to the arguments parameter of this function when the script is invoked to populate a validation provider pick list in the service catalog, this contains the validation parameters information fatal method fatal description writes a fatal message to the server log definition console fatal(string logmessage) parameters logmessage the message string to be logged example you can log a fatal message with the following script console fatal("this is a fatal message!"); error method error description writes an error message to the server log definition console error(string logmessage) parameters logmessage the message string to be logged example you can log an error message with the following script console error("this is an error message!") warning method warning description writes a warning message to the server log definition console warn(string logmessage) parameters logmessage the message string to be logged example you can log a warning message with the following script console warn("this is a warning message!") informational method informational description writes an informational message to the server log definition console info(string logmessage) parameters logmessage the message string to be logged example you can log an informational message with the following script console info("this is an informational message!"); debug method debug description writes a debug message to the server log definition console debug(string logmessage) parameters logmessage the message string to be logged example you can log a debug message with the following script console debug("this is a debug message!"); log method log description writes a log message to the server log definition console log(string logmessage) parameters logmessage the message string to be logged example you can log a log message with the following script console log("this is a log message!"); getwebservicefromurl method getwebservicefromurl description gets the web service instance object that invokes the web service definition object getwebservicefromurl(string serviceurl, string servicename, string username, string password) object getwebservicefromurl(string serviceurl, string servicename, string username, string password, string wsdlpath) parameters serviceurl the url where the web service is located servicename the name of the web service username the user name of the credential needed to get the web service instance password the password related to the user name wsdlpath if the web service does not support querying wsdl documents, then this parameter contains the location where the wsdl for the web service is available this is the name of the wsdl document as it is listed in the wsdl and script repository workspace return type returns the object that is the web service instance whose methods can be called examples var serviceinstance = getwebservicefromurl(" http //wsf cdyne com/weatherws/weather asmx ", "weather", null, null); var serviceinstance = getwebservicefromurl(" http //www webservicex net/uszip asmx ", "uszip", null, null); var serviceinstance = getwebservicefromurl(" http //sap local 8000 /sap/bc/srt/rfc/sap/ict service desk api/100/ict service desk api/ict service desk api", "ict service desk api", null, null, 'name of sap wsdl document in the repository'); var serviceinstance = getwebservicefromurl(null, "uszip", null, null, " http //www webservicex net/uszip asmx?wsdl "); var serviceinstance = getwebservicefromurl(' http //www webservicex net/uszip asmx ', "uszip", null, null, " http //www webservicex net/uszip asmx?wsdl "); getwebservice method getwebservice description gets the web service instance object that is necessary to invoke the web service definition getwebservice(string servicereferencename, string servicename) parameters servicereferencename the name of the service reference the name should be unique for each script it identifies the service address url within the script servicename the name of the web service return type returns the object that is the web service instance whose methods can be called example var servicereferencename = "testintegration"; var wsdladdress = "testintegration testintegration address"; var userid = "testintegration testintegration login"; var pwd = "testintegration testintegration password"; var servicename = "frsheatintegration"; var serviceinstance = getwebservice (testintegration, frsheatintegration); invokemethod method invokemethod description invokes the given web service method definition object service invokemethod(string methodname, object\[] arguments); object service invokemethod(string methodname, object arguments); parameters methodname the name of the web method to invoke arguments the input parameters for the web method either an array of positional arguments or an object containing the name and value of the parameter return type returns the result of the web service call as an object example var serviceinstance = getwebservicefromurl(" http //www webservicex net/uszip asmx ", "uszip", null, null); var xmldoc = serviceinstance invokemethod("getinfobystate", \[ state ]); var xmldoc = serviceinstance invokemethod("getinfobystate", { 'usstate' state }); getcookievalue method getcookievalue description accesses the authentication token in the cookie, which is used when authenticating a user name and password definition getcookievalue(string url, string name) parameters url the associated url of the cookie that is being accessed name the name of the cookie whose value needs to be retrieved return type returns the value of the authentication token example you can retrieve the cookie called authtoken with the following script var wsdladdress = "sunrise webservicexsunrise address"; var userid = "sunrise webservicexsunrise login"; var pwd = "sunrise webservicexsunrise password"; var servicecall = "sunsetriseservice"; var serviceinstance = getwebservicefromurl(wsdladdress, servicecall, userid,pwd); var result = serviceinstance invokemethod(methodcall, paramvalues); var authtoken = serviceinstance getcookievalue('/', 'authtoken'); executequickaction method executequickaction description executes the specific quick action with optional arguments, this method executes the specific quick action defined on the specified business object affecting the specified recid definition executequickaction(string actionname) executequickaction(string actionname, string tableref, string recid) parameters actionname the name of the quick action tableref the table reference of the table where the record is created recid the recid of the record whose data is needed example the application executes the problem workaround notification for incident owner quick action on the current object context of the incident business object executequickaction("problem workaround notification for incident owner"); the application executes the problem workaround notification for incident owner quick action on the specified incident, where incident recid is the script variable that is initialized with the recid of the target incident executequickaction("problem workaround notification for incident owner", "incident#", incident recid); executescript method executescript description executes the script associated with the specified external business object definition executescript(string bodesignername, object arguments) parameters bodesignername the name of the external business object arguments the input parameters for the external business object specified by the bodesignername parameter return type the json object that is returned using the setreturndata web method example var bodesignername = related bo frs ws dsm softwarerevision designer name; var arguments = { requester { boname current context bo designer name } }; var scriptreturn = executescript(bodesignername, arguments); setreturndata method setreturndata description uses the value to return data for a pick list or data that is called from another synchronization script if you call this method more than once, the application uses the value set by the last call definition setreturndata(object) setreturndata(object\[] jsonobject) parameters jsonobject when called from another script using the executescript web method, this is any json data that the script returns to the calling script when called to retrieve records for a pick list, this is an array of key value pairs for example function state(name, code) { this name = name; this code = code; } return type for a pick list, the return type is an array of objects that contains the fields defined in the external business objects for a synchronization script, the return type can be any type example // http //www webservicex net/uszip asmx function zipinfo(city, state, zip, areacode, timezone) { this city = city; this state = state; this zip = zip; this areacode = areacode; this timezone = timezone; } function getcities(state) { if (!state) return \[]; var serviceinstance = getwebservice("uszip", "uszip"); var xmldoc = serviceinstance invokemethod("getinfobystate", \[ state ]); var list = xmldoc childnodes; if (!list) return \[]; var cities = {}; var count = list count; for (i = 0; i < count; i++) { try { var node = list\[i]; var info = new zipinfo(node\["city"] innertext, node\["state"] innertext, node\["zip"] innertext, node\["area code"] innertext, node\["time zone"] innertext); cities\[info city touppercase()] = info; } catch (error) { console log("error during processing of city "); } } var result = \[]; for (city in cities) result push(cities\[city]); return result; } var state = null; if (!!heatcontext picklist) { try { state = heatcontext picklist constraint conditions\[0] value; } catch (error) { console log(error tostring()); } // we are returning this data for pick list setreturndataforcondition(!state ? \[] getcities(state), { state state}); } else if (!!heatcontext arguments && !!heatcontext arguments synchronize && !!heatcontext arguments state) { state = heatcontext arguments state; synchronizeheatdata(heatcontext businessobject designername, \["state", "city"], getcities(state), { state state}); } else if (!!heatcontext arguments && !!heatcontext arguments state) { // this will return the list of cities for a given state when it is called through executescript state = heatcontext arguments state; setreturndata(!state ? \[] getcities(state)); } setreturndataforcondition method setreturndataforcondition description returns data for a pick list if you call this method more than once, the application uses the value set by the last call definition setreturndataforcondition(object\[] records, object wherecondition) parameters records when called to retrieve records for a pick list, this is an array of key value pairs for example function state(name, code) { this name = name; this code = code; } wherecondition defines the scope of the data that is being operated on for example, in the example for setreturndata docid\ qociljcfllhuopxuwihvd , it is the current state code for which the data is being retrieved from external source return type an array of objects that contains the fields defined in the external business objects example see the example for setreturndata docid\ qociljcfllhuopxuwihvd create method create description creates a new record in definition dbobject create(string tableref) parameters tableref the table reference of the table where the record is created example you can create a new incident with the following script var newincident = create('incident#'); get method get description gets the object for an existing record using its record id from the specified table reference definition get(string tableref, string recid) get(string tableref, string fieldname, object value) parameters tableref the table reference of the table where the record will be created recid the recid of the record whose data is needed fieldname the name of the field in the current business object value the value of the field specified by the fieldname parameter example use the following script to call the built in function called currentuserrecid to read data, such as the last name of the current user var employee = get('employee#', '$(currentuserrecid())') var lastname = employee fields\['lastname']; the following example retrieves the incident with the incident number of 100001 get("incident#", "incidentnumber", 100001) update method update description updates a record definition update(object data) parameters data a json like object ({\<key1> '\<value>', \<key2> '\<value2>', }) that contains the key value pairs to be updated in the record object (dbobject) on which this method is invoked example you can use this method to edit or update a record for example, to edit two fields, use the following script, which gets the number and recid of the current incident and then updates the two fields called impact and symptom var incident = get('incident#', '$(recid)'); incident update({ impact 'medium', symptom 'problem' }); another use case is to automatically create a new incident with fields auto filled whenever a domain account is locked for example, the following script creates a new incident and then updates that incident with new field values stating the symptom clearly as domain account locked var newincident = create('incident#'); newincident update({ category 'account lockout', impact 'medium', profilelink recid '$(currentuserrecid())', service 'desktop service', status 'active', subject 'cannot login to windows', symptom 'customer failed to login to windows for more'+ 'than 3 times and domain account is locked', urgency 'medium' }); addlink method linkwebservice description the web service is used to link two different business objects definition addlink(string tableref, string id, string othertableref, string otherid, string relationshiptag) parameters string tableref business object name string id business object rec id othertableref business object name that should be linked string otherid business object rec id that should be linked string relationshiptag relationship of the two business objects examples linking an incident to a change addlink('incident#','089addf649dc4ed1a8d2b8c067d2ea92', 'change#', '0c88f78b5f4d42aca95d202f42084b72', 'incidentassociateschange'); linking problem to an incident addlink('incident#','12de7c19a6f94457bf8d168493dda475', 'problem#', '67da12c70e5940babb926fde0d9e238d', 'problemassociatesincident'); updatefield method updatefield description updates a field of a record definition updatefield(string fieldname, string fieldvalue) parameters fieldname the name of the field to update fieldvalue the value of the field example use the following script to edit the subject field incident updatefield('subject', 'please open a new record'); search method search description gets a collection without any search conditions definition search(string tableref) search(string tableref, string savedsearch) search(string tableref, object simplesearch) returns returns an object that provides two sets of functionalities the first set of functions creates, joins, and customizes search behaviors use the relateditems property to access or join the current business object with its related items use the relationship name through relateditems to build join conditions use where(object simplesearch) to add conditions to the related business objects use distinct() to add distinct behavior to the search function use top(nrecords) to restrict the number of records that needs to be retrieved the second set of functions enumerates the result of the search operation tableref the business object name of the search result first() returns the first business object or 'null' if the result is empty the returned business object has a property called fields that is an object of fields and their values current returns the current business object when movenext() returns true the returned business object has a property called fields that is an object of fields and their values movenext() moves the cursor to the next business object if present and returns true otherwise, it returns false indicating that there are no more business objects to access reset() resets the cursor to the beginning of the result list close() closes the result set and frees up any resources used by the search you must fully define the search criteria and behaviors before starting to process the results once you start processing the results, you must process the entire result set otherwise, further database operations can cause errors and throw exceptions you can completely process the result set by either enumerating all business objects using the movenext() function it until it returns false, or by calling the close() function • parameters tableref the table reference of the table from which the results are retrieved savedsearch the name of the saved search simplesearch additional search filter example use the following script to get a collection without any search conditions search('incidentstatus#'); the following is another example of a script to get a collection search('incident#', { status 'active', profilelink recid '$(currentuserrecid())' }); use any of the following scripts to get the incident with the number 10424 • var incident = get('incident#', '8d9edc222216490b895ff8c3d3b5d4ee'); • var incident = get('incident#', 'incidentnumber', 10424); • var incident = search('incident#', { incidentnumber 10424 }) first(); this is another example var incident = null; var result = search('incident#', { status 'active' }); while (result movenext()) { var obj = result current; if (obj fields\["incidentnumber"] == 100) { incident = obj; break; } } result close(); use the following script to search for records based on relationships in this example, the script retrieves the tasks for the specified incident var tasks = get('incident#', '$(recid)') relateditems\['task#assignment rev3']; var votes = search('change#', {status 'scheduled'}) relateditems\['frs approval# '] relateditems\['frs approvalvotetracking# ']; where method where description filters a collection of objects that satisfy a condition use the where method with the search method see also search docid\ qociljcfllhuopxuwihvd and update docid\ qociljcfllhuopxuwihvd definition dbobjectcollection where(string condition) parameters condition the conditional expression to base the output on example use the following script to select records where the status of tasks is "rejected" var rejectingitems = search('task#assignment') where({status 'rejected'}) use the following script to search for records using a set of validated fields in this example, the script retrieves team members who have tasks with a rejected status var rejectingteams = search('task#assignment') where({status 'rejected'}) // select records where status of the tasks = rejected relateditems\['owner => employee#'] relateditems\['team => standarduserteam#'] distinct() // selects unique records without duplicates top(20); // selects the top 20 records executewebrequest method executewebrequest description executes an http web request and returns the response of the request definition executewebrequest(string method, string url, string postdata, object settings); executewebrequest(string method, string url, byte\[] postdata, object settings); parameters method valid http request methods such as get, post, head, and delete url the http request url including the query string values postdata contains post data to be sent as part of the request, properly formatted and encoded in string or byte\[] settings optional contains a json object its members are also optional headers a json object containing additional http request headers including customer headers for example { "host" " www example com ", "referer" " ", "user agent" "heatsm scripting", "content type" "application/x www form urlencoded" } cookies json object and it is optional if passed, cookie name is used as property name and its value as property value for example { "cookiename" "cookievalue" } skipservercertificatevalidation a boolean value that controls how to handle the certificates error during an https request call servercertificatehash optional a string value if provided, it skips certificate errors if the hash value of a certificate matches this value allowautoredirect automatically processes the request call redirect and returns the response of the redirect request username optional the user name of the credential password optional the password of the credential returns returns a response from an http request call this return value is a json object containing the following properties statuscode the numerical value of the response status code see https //msdn microsoft com/en us/library/system net httpstatuscode(v=vs 110) aspx https //msdn microsoft com/en us/library/system net httpstatuscode(v=vs 110) aspx statusdescription the description of the status code characterset the character set name of the r esponse data contenttype the type of response content contentlength the length of the response content lastmodified the last modified header of the response cookies a json object containing cookies related to the response data either string (for text content) or byte\[] (for non text content) example // javascript object to wrap rest api(s) function customservice(host, username, password) { 'use strict'; // private members var host = host; var username = username; var password = password; var cookies = null; var sessioninfo = null; var getwwwformurlencodeddata = function (obj) { var encoded = '', separator = ''; for (var key in obj) { var value = obj\[key]; var encodedkey = heatutility htmlencode(key tostring()); if (typeof value === 'undefined' || null == value) encoded += separator + encodedkey; else if (value instanceof array) { for (var i = 0; i < value length; i++) { encoded += separator + encodedkey + '=' + heatutility htmlencode(value\[i] + ''); separator = '&'; } } else encoded += separator + encodedkey + '=' + heatutility htmlencode(value tostring()); separator = '&'; } return encoded; }; var getrequestsettings = function () { return { headers {}, cookies cookies, skipservercertificatevalidation true, username null, password null, allowautoredirect false }; }; var getjsonrequestsettings = function () { return { headers { 'content type' 'application/json' }, cookies cookies, skipservercertificatevalidation true, username null, password null, allowautoredirect false }; }; var isauthenticated = function () { return !!sessioninfo && !!sessioninfo tenantid; }; var login = function () { var url = host + '/patchweb/tenant/v1/login?' + getwwwformurlencodeddata({ username username, password password }); var response = executewebrequest('get', url, null, getrequestsettings()); if ((response != null) && (response statuscode == 200) && (response contenttype == 'application/json')) { cookies = response cookies; var sessioninfo = json parse(response data); if (!!sessioninfo && !!sessioninfo tenantid) { sessioninfo = sessioninfo; return true; } } return false; }; var getallendpoints = function (groups) { if (!isauthenticated()) throw 'either login failed or please login '; var url = host + '/patchweb/patchmanagement/v1/' + sessioninfo tenantid + '/endpointpatchstates?groups=' + heatutility htmlencode(groups); var response = executewebrequest('get', url, null, getrequestsettings()); if ((response != null) && (response statuscode == 200) && (response contenttype == 'application/json')) return json parse(response data); console error(response); }; // public function this isauthenticated = isauthenticated; this login = login; this getallendpoints = getallendpoints; } var service = new customservice(' https //www example com ', 'username', 'password'); service login(); if (service isauthenticated()) { var endpoints = service getallendpoints('default,excluded'); console debug(endpoints); } else console error('login failed for user username '); synchronizeallheatdata method synchronizeallheatdata description synchronizes the provided records against all records for the business object in the application by doing the following deletes any records in the application (for the business object) that are not found in the provided records inserts any records in the application (for the business object) that are found in the provided records that do not already exist in the application updates records in the application (for the business object) against the provided records return type this function returns an array of recids of the records definition object\[] synchronizeallheatdata(string designername, string\[] primarykey, object\[] records) parameters designername name of the business object that is being synchronized primarykey an array of fields that uniquely identify each record records a list of json key value pairs that contains fields and their corresponding values example function state(name, code) { this name = name; this code = code; } var result = \[]; result push(new state('alabama', 'al')); result push(new state('montana', 'mt')); result push(new state('alaska', 'ak')); result push(new state('nebraska', 'ne')); result push(new state('arizona', 'az')); result push(new state('nevada', 'nv')); result push(new state('arkansas', 'ar')); result push(new state('new hampshire', 'nh')); result push(new state('california', 'ca')); result push(new state('new jersey', 'nj')); result push(new state('colorado', 'co')); result push(new state('new mexico', 'nm')); result push(new state('connecticut', 'ct')); result push(new state('new york', 'ny')); result push(new state('delaware', 'de')); result push(new state('north carolina', 'nc')); result push(new state('florida', 'fl')); result push(new state('north dakota', 'nd')); result push(new state('georgia', 'ga')); result push(new state('ohio', 'oh')); result push(new state('hawaii', 'hi')); result push(new state('oklahoma', 'ok')); result push(new state('idaho', 'id')); result push(new state('oregon', 'or')); result push(new state('illinois', 'il')); result push(new state('pennsylvania', 'pa')); result push(new state('indiana', 'in')); result push(new state('rhode island', 'ri')); result push(new state('iowa', 'ia')); result push(new state('south carolina', 'sc')); result push(new state('kansas', 'ks')); result push(new state('south dakota', 'sd')); result push(new state('kentucky', 'ky')); result push(new state('tennessee', 'tn')); result push(new state('louisiana', 'la')); result push(new state('texas', 'tx')); result push(new state('maine', 'me')); result push(new state('utah', 'ut')); result push(new state('maryland', 'md')); result push(new state('vermont', 'vt')); result push(new state('massachusetts', 'ma')); result push(new state('virginia', 'va')); result push(new state('michigan', 'mi')); result push(new state('washington', 'wa')); result push(new state('minnesota', 'mn')); result push(new state('west virginia', 'wv')); result push(new state('mississippi', 'ms')); result push(new state('wisconsin', 'wi')); result push(new state('missouri', 'mo')); result push(new state('wyoming', 'wy')); if (!!heatcontext picklist) { // we are returning this data for pick list setreturndata(result); } else if (!!heatcontext arguments && !!heatcontext arguments webservice) { if (heatcontext arguments webservice synchronize == 'selected') { // this synchronizes only the records available in the given result list/array // any records present here and in database will be updated // any records present here and not in database will be inserted synchronizeheatdata(heatcontext businessobject designername, \['code'], result); } else if (heatcontext arguments webservice synchronize == 'all') { // this synchronizes only the records available in the given result list/array // any records present here and in database will be updated // any records present here and not in database will be inserted // any records in database but not in this list will be deleted synchronizeallheatdata(heatcontext businessobject designername, \['code'], result); } else if (heatcontext arguments webservice synchronize == 'clear') { // all records in database would be deleted since the given list is empty synchronizeallheatdata(heatcontext businessobject designername, \['code'], \[]); } } synchronizeallheatdatawithrelated method synchronizeallheatdatawithrelated description synchronizes the provided records against all records for the business object and any related business objects in the application by doing the following deletes any records in the application (for the business object and any related business objects) that are not found in the provided records inserts any records in the application (for the business object and any related business objects) that are found in the provided records that do not already exist in the application updates records in the application (for the business object and any related business objects) against the provided records return type this function returns an array of recids of the records definition object\[] synchronizeallheatdatawithrelated(string designername, string\[] primarykey, object\[] records, object keysofrelatedobjects) parameters designername name of the business object that is being synchronized primarykey an array of fields that uniquely identify each record records a list of json key value pairs that contains fields and their corresponding values keysofrelatedobjects a json object that is constructed as follows { relationshipname string\[] primarykey } example function getexternaldata(ctx) { // your code to get data from external source return \[]; } function toheatrecords(softwarelist, sofrwaretype, schematagtosoftwaretype) { var arrfinalizedsoftwarelist = \[]; var isoptionalsoftware = (sofrwaretype == 'optionalsoftware'); for (var item in softwarelist) { var srcobject = softwarelist\[item]; var dsmsoftwareguid = srcobject uniquekey uniqueid; var softwarerevision = ''; var islastreleasedrev = false; var uninstallsupported = false; var reinstallsupported = false; for (var idx in srcobject propgrouplist) { var tmpobjpropgrp = srcobject propgrouplist\[idx]; for (var idx2 in tmpobjpropgrp propertylist) { var tmpobjprop = tmpobjpropgrp propertylist\[idx2]; if (tmpobjprop tag == 'softwarerevision') softwarerevision = tmpobjprop internalvalue; if ((tmpobjprop tag == 'islastreleasedrev') && (tmpobjprop internalvalue === true)) islastreleasedrev = true; if ((tmpobjprop tag == 'supportsuninstall') && (tmpobjprop internalvalue === true)) uninstallsupported = true; if ((tmpobjprop tag == 'supportsreinstall') && (tmpobjprop internalvalue === true)) reinstallsupported = true; } } // create/update software revision and heat software (frs dsm software) var relatedobjlist = { 'frs ws dsm softwarecontainsfrs ws dsm softwarerevision' \[{ dsmsoftwareid srcobject id, dsmsoftwareguid dsmsoftwareguid, dsmcreateddate srcobject creationdate, dsmmodifieddate srcobject modificationdate, grouptype srcobject grouptype, softwarename srcobject name, parentcontainerid srcobject parentcontid, revision softwarerevision, schematag srcobject schematag, softwaretype softtype, islastreleasedrev islastreleasedrev, uninstallable uninstallsupported, reinstallable reinstallsupported }], 'frs ws dsm softwarecontainsfrs dsm software' { issoftwarepackagereleased true } }; // create/update software package var finalizedsoftware = { fields { dsmsoftwareguid dsmsoftwareguid, heatsmsoftwaretype sofrwaretype }, related relatedobjlist }; var softtype = (!!srcobject schematag && !!schematagtosoftwaretype\[srcobject schematag]) ? schematagtosoftwaretype\[srcobject schematag] softwaretype 'undefined'; if (islastreleasedrev) { finalizedsoftware fields name = srcobject name; finalizedsoftware fields isoptionalsoftware = isoptionalsoftware; finalizedsoftware fields schematag = srcobject schematag; finalizedsoftware fields softwaretype = softtype; finalizedsoftware fields lastreleasedsoftwareid = srcobject id; } arrfinalizedsoftwarelist push(finalizedsoftware); } return arrfinalizedsoftwarelist; } function getsoftwareguid(softwarelist) { if (object prototype tostring call(softwarelist) !== '\[object array]') return null; var array = \[]; for (var i = 0; i < softwarelist length; i++) array push(softwarelist\[i] fields dsmsoftwareguid); return array; } function synchronizeheatsm(isall, sofrwaretype, schematagtosoftwaretype) { if (isall) { var arrfinalizedsoftwarelist = \[]; array prototype push apply(arrfinalizedsoftwarelist, toheatrecords(getexternaldata('availablesoftware'), 'availablesoftware', schematagtosoftwaretype)); array prototype push apply(arrfinalizedsoftwarelist, toheatrecords(getexternaldata('optionalsoftware'), 'optionalsoftware', schematagtosoftwaretype)); return synchronizeallheatdatawithrelated('frs ws dsm software', \['dsmsoftwareguid'], arrfinalizedsoftwarelist, { 'frs ws dsm softwarecontainsfrs ws dsm softwarerevision' \['dsmsoftwareguid'], 'frs ws dsm softwarecontainsfrs dsm software' \[] }); } else { var arrfinalizedsoftwarelist = toheatrecords(getexternaldata(sofrwaretype), sofrwaretype, schematagtosoftwaretype); var arrdsmsoftwareguidlist = getdsmsoftwareguid(arrfinalizedsoftwarelist); return synchronizeheatdatawithrelated('frs ws dsm software', \['dsmsoftwareguid'], arrfinalizedsoftwarelist, { 'frs ws dsm softwarecontainsfrs ws dsm softwarerevision' \['dsmsoftwareguid'], 'frs ws dsm softwarecontainsfrs dsm software' \[] }, { dsmsoftwareguid arrdsmsoftwareguidlist }); } } synchronizeheatdata method synchronizeheatdata description synchronizes the provided records against all records that meet a certain condition, for the business object in the application by doing the following deletes any records in the application (that meet a certain condition, for the business object) that are not found in the provided records inserts any records in the application (that meet a certain condition, for the business object) that are found in the provided records that do not already exist in the application updates records in the application (that meet a certain condition, for the business object) against the provided records return type this function returns an array of recids of the records definition object\[] synchronizeheatdata(string designername, string\[] primarykey, object\[] records, object syncdatacondition) parameters designername name of the business object that is being synchronized primarykey an array of fields that uniquely identify each record records a list of json key value pairs that contains fields and their corresponding values syncdatacondition specifies when to synchronize the data example see the example for synchronizeallheatdata docid\ qociljcfllhuopxuwihvd synchronizeheatdatawithrelated method synchronizeheatdatawithrelated description synchronizes the provided records against all records that meet a certain condition, for the business object and any related business objects, in the application by doing the following deletes any records in the application (that meet a certain condition, for the business object and any related business objects) that are not found in the provided records inserts any records in the application (that meet a certain condition, for the business object and any related business objects) that are found in the provided records that do not already exist in the application updates records in the application (that meet a certain condition, for the business object and any related business objects) against the provided records return type this function returns an array of recids of the records definition object\[] synchronizeheatdatawithrelated(string designername, string\[] primarykey, object\[] records, object keysofrelatedobjects, object syncdatacondition) parameters designername name of the business object that is being synchronized primarykey an array of fields that uniquely identify each record records a list of json key value pairs that contains fields and their corresponding values keysofrelatedobjects a json object that is constructed as follows { relationshipname string\[] primarykey } syncdatacondition specifies when to synchronize the data example see the example for synchronizeallheatdatawithrelated docid\ qociljcfllhuopxuwihvd htmlencode method heatutility htmlencode description encodes html special characters like ?, &, <, >, and so on, that are found in the passed in parameter string see https //msdn microsoft com/en us/library/73z22y6h(v=vs 110) aspx https //msdn microsoft com/en us/library/73z22y6h(v=vs 110) aspx for more information returns encoded html string definition string heatutility htmlencode(string s); parameters s string containing the html special characters to be encoded example heatutility htmlencode ("\<script>unsafe\</script>"); htmldecode method heatutility htmldecode description decodes html special characters like ?, &, <, >, and so on, that are found in the passed in parameter string see https //msdn microsoft com/en us/library/7c5fyk1k(v=vs 110) aspx https //msdn microsoft com/en us/library/73z22y6h(v=vs 110) aspx for more information returns decoded html string definition string heatutility htmldecode(string s); parameters s string containing the html special characters to be decoded example heatutility htmldecode ("\<script\>unsafe\</script\>"); hextobytes method heatutility hextobytes description converts a stream of bytes that are encoded in hex to bytes returns bytes converted from hex definition byte\[] heatutility hextobytes(string hex); parameters hex string containing hex characters example heatutility hextobytes ("0123456789abcdefabcdef"); bytestostring method heatutility bytesto string description converts a stream of bytes to a string see https //msdn microsoft com/en us/library/744y86tc(v=vs 110) aspx https //msdn microsoft com/en us/library/744y86tc(v=vs 110) aspx for more information returns string converted from bytes definition string heatutility bytestostring(byte\[] data, string encoding); parameters data encoded stream of bytes encoding the encoded format can be one of the following ascii, utf7, utf8, utf16, utf16be, and utf32 example heatutility bytestostring(\[48, 49, 50, 51, 52, 53, 54, 55, 56, 57], 'utf8'); loadxml method heatutility loadxml description creates an xml document object from the given xml text see https //msdn microsoft com/en us/library/system xml xmldocument loadxml(v=vs 110) aspx https //msdn microsoft com/en us/library/system xml xmldocument loadxml(v=vs 110) aspx for more information returns an xml document object created from the given xml string definition xmlelement heatutility loadxml(string xml); parameters xml xml in string form example heatutility loadxml("\<books>\<book name="author name"publisher="some publisher">\</book>\</books>"); getcultureinfo method heatutility getcultureinfo description gets the culture instance for the given culture id or locale id see yck8b540(v=vs 110) aspx https //msdn microsoft com/en us/library/yck8b540(v=vs 110) aspx or w4deeh00(v=vs 110) aspx https //msdn microsoft com/en us/library/w4deeh00(v=vs 110) aspx for more information returns a cultureinfo object for the given culture or locale definition cultureinfo heatutility getcultureinfo(string id); cultureinfo heatutility getcultureinfo(int lcid); parameters id the culture id an example us en us lcid the culture locale id an example is 0x0409 example heatutility getcultureinfo("en us"); heatutility getcultureinfo(0x0409); heatutility getcultureinfo(1033); gettimezoneinfo method heatutility gettimezoneinfo description gets the time zone information for the given microsoft windows time zone or iana time zone see system timezoneinfo findsystemtimezonebyid(v=vs 110) aspx https //msdn microsoft com/en us/library/system timezoneinfo findsystemtimezonebyid(v=vs 110) aspx for more information returns a timezoneinfo object for the given time zone the timezoneinfo object contains the data from timezones workspace see working with dates, times, and time zones docid 5wbikekjggbtk efy2jmy for more information about timezone workspace definition timezoneinfo heatutility gettimezoneinfo(string ianaorwindowstimezone); parameters ianaorwindowstimezone the microsoft windows or iana time zone example heatutility gettimezoneinfo("pacific standard time"); heatutility gettimezoneinfo("america/los angeles"); hash method heatutility hash description generates the hash value of the given string text using the specified algorithm see https //msdn microsoft com/en us/library/wet69s13(v=vs 110) aspx https //msdn microsoft com/en us/library/wet69s13(v=vs 110) aspx for more information returns the generated hash value definition byte\[]heatutility hash(string hashalgorithm, string data); byte\[]heatutility hash(string hashalgorithm, byte\[] data); parameters hashalgorithm the hashing algorithm to use data the data to be hashed example heatutility hash("sha1","this message needs to be signed "); heatutility hash("sha1", \[100, 101,102,103, 104, 105, 200]); keyedhash method heatutility keyedhash description generates the hash value of the given string text using the specified algorithm and the key see https //msdn microsoft com/library/s5zz2x4d(v=vs 100) aspx https //msdn microsoft com/library/s5zz2x4d(v=vs 100) aspx for more information returns the generated hash value definition byte\[]heatutility keyedhash(string hashalgorithm, byte\[] key, string data); byte\[]heatutility keyedhash(string hashalgorithm, byte\[] key, byte\[] data); parameters hashalgorithm the hashing algorithm to use key an array of bytes that contain the key data the data to be hashed example heatutility keyedhash ("hmacsha1, \[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], "this message needs to be signed "); heatutility keyedhash ("hmacsha1, \[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], \[100, 101,102,103, 104, 105, 200]);
