Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Setting the Configuration item in the Incident form by Matching the Alert short description

Shantanu1
Tera Guru

Hi Experts!

 

I have created a flow designer to get Incidents created via Alerts received.

 

I have a requirement where if the Alert description has letter "CN" then the INC configuration item have an Application CI with sys ID "X". 

 

I am trying to access the Alert data in the below screenshot and return a sys ID for the Configuration item to populated the INC but seems it is failing. Any help will be greatly appreciated.

 

 

Shantanu1_0-1695828048592.png

 

1 ACCEPTED SOLUTION

@Shantanu1 

 

Replace entire code with the following one.

 

var shortDesc = fd_data.subflow_inputs.ah_alertgr.description;

 

if(shortDesc.indexOf("CN") != -1){

return "sys_ID1";

} else {

return "sys_ID2";

}

 

 

Thanks,
Anvesh

View solution in original post

6 REPLIES 6

AnveshKumar M
Tera Sage
Tera Sage

Hi @Shantanu1 

Try this,

 

if(shortDesc.indexOf("CN") != -1){

return "your_sys_id";

}

Thanks,
Anvesh

Thanks for the response @AnveshKumar M , I see the INC created but looks like the CI is not updated. I am using the below script:

 

function containsSubstring(mainString, substring) {
return mainString.indexOf(substring) !== -1;
}

var shortDesc = fd_data.subflow_inputs.ah_alertgr.description;

return shortDesc

if(shortDesc.indexOf("CN") != -1){
return "sys_ID1";
} else {
return "sys_ID2";
}

Shantanu1
Tera Guru

The output now shows like this:

 

Shantanu1_0-1695831167773.png

 

@Shantanu1 

 

Replace entire code with the following one.

 

var shortDesc = fd_data.subflow_inputs.ah_alertgr.description;

 

if(shortDesc.indexOf("CN") != -1){

return "sys_ID1";

} else {

return "sys_ID2";

}

 

 

Thanks,
Anvesh