How to use split function is explained in this video.
Capability of JavaScript split function explained using ServiceNow notification and inbound action.
We can use the JavaScript split function in inbound actions to extract the required information and update the target record based on that.
------------------------------------------------------------------------------
Script: split function to populate the fields values
-------------------------------------------------------------------------------
var subjectString = "Incident: ${number} has been moved to ${state}";
var fieldsArray = subjectString.split("${");
for(var i=1; i != fieldsArray.length; i++){
var field = fieldsArray[i].split("}");
field = field[0];
var fieldValue = getIncidentFieldValue(field);
subjectString = subjectString.replace("${"+field+"}", fieldValue);
}
gs.info(subjectString)
function getIncidentFieldValue(field){
var grInc = new GlideRecord("incident");
if(grInc.get("number", "INC0000060")){
return grInc.getDisplayValue(field);
}
}
Note:
Less than symbol is not allowed in the description, hence added != in the for loop in above code.
Watch also:
JavaScript array functions explained.
• JavaScript Array Methods or Functions | Ja...
#servicenow #servicenowdeveloper #servicenowadmin #servicenowcommunity #servicenowconsulting
On this page of the site you can watch the video online JavaScript split function explained with best use case | Notification | Inbound Action | ServiceNow with a duration of hours minute second in good quality, which was uploaded by the user ServiceNow Universe 28 July 2023, share the link with friends and acquaintances, this video has already been watched 461 times on youtube and it was liked by 16 viewers. Enjoy your viewing!