JavaScript split function explained with best use case | Notification | Inbound Action | ServiceNow

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 Metho...
#servicenow #servicenowdeveloper #servicenowadmin #servicenowcommunity #servicenowconsulting

Пікірлер: 3

  • @kirankumarbastawadi1367
    @kirankumarbastawadi1367

    🎉 fantastic

  • @kirankumarbastawadi1367
    @kirankumarbastawadi1367

    Super presentation 🎉

  • @Dara-eq7qw
    @Dara-eq7qw

    'promosm' ☀️

Келесі