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.

How to get Job Name from incident descption

ack
Tera Contributor

Hi All,

 

I am trying to get job name from incident description and past job name in other field.

below is description of incident (format is same always , only values will change)

//////////////////////////////////////

 

Scheduler host: plcmjob01.aaa-acg.net

Job name:                         MKT_W_Weekly-Household-Aggregate-Combine
Application name:                MKT_Weekly_Household_Aggregate_And_Oibee
Group name:                          2#
Status:                                   FAILURE
Job run machine:                 pxsasrpt01
Job run identifier:                   3419.9369764.1
Job start time:                         10/01/2022 12:04:48
Job completion time:                 10/01/2022 14:07:08
Exit code:                                      3

 

/////////////

 

please help me to get job name.

Thanks in advance.

2 REPLIES 2

Jyoti Jadhav9
Tera Guru

Hi @ack 

You can write Before insert/Update Business rule with the Condition "Description contains Job name:" and try the below script. :

 

(function executeRule(current, previous /*null when async*/) {
    // Add your code here
    var job_name = 'Job name:';
    var descriptionArr = current.description.split('\n');
    var job_name1 = descriptionArr[1].substring(descriptionArr[1].indexOf(job_name) + job_name.length, descriptionArr[1].length);
    current.short_description = job_name1.trim();
})(current, previous);

Screenshots:

Jyoti4_0-1707237456694.png 

Jyoti4_1-1707237586552.png

O/P:

Jyoti4_2-1707237657688.png

Please hit the like button if my suggestion has helped you in any way.
Please mark correct if my response has solved your query.

 

Thanks & Regards

Jyoti Jadhav

 

 

Abhishek M
Kilo Guru

Hi @ack,

 

Considering "Job Name:" to be fixed in your description and after that application name comes always in new line you can try with following piece of code

 

var jName = ((text.split("Job name:")[1]).split("\n")[0]).trim();
text will store the entire incident description, you can tweak this code from chatgpt