Append every time changed priority field to short description on incident

rmaroti
Tera Contributor

Hello ,

can anyone help me- my requirement is when we change urgency and impact it will change priority so  I want to  append new priority change value every time with existing value of short description

for ex-

Priority- 1-critical

Short Description=  Printer is not working

 

Expected Output is-

Short Description= 1-critical Printer is not working

when again changed priority from 1-critical to 2-High then it need to be

Short Description= 2-High 1-critical Printer is not working

 

can any one tell how to achieve it.

 

 

1 ACCEPTED SOLUTION

SANDEEP28
Mega Sage

@rmaroti  You need to create onChange client script on "Priority" field as below

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

    if (newValue && g_form.getValue('short_description')) {

		var priority = g_form.getValue('priority');
		var priorityDisplayValue = g_form.getOption('priority', priority).text;
                var short_desc = priorityDisplayValue + ' ' +g_form.getValue('short_description');

		g_form.setValue('short_description', short_desc);

    }

}

 

SANDEEP28_1-1704725707175.png

 

 

I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!

 

 

 

 

 

View solution in original post

3 REPLIES 3

SANDEEP28
Mega Sage

@rmaroti  You need to create onChange client script on "Priority" field as below

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

    if (newValue && g_form.getValue('short_description')) {

		var priority = g_form.getValue('priority');
		var priorityDisplayValue = g_form.getOption('priority', priority).text;
                var short_desc = priorityDisplayValue + ' ' +g_form.getValue('short_description');

		g_form.setValue('short_description', short_desc);

    }

}

 

SANDEEP28_1-1704725707175.png

 

 

I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!

 

 

 

 

 

Ankur Bawiskar
Tera Patron
Tera Patron

@rmaroti 

you can use before update BR

Condition: Priority Changes

Script:

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	current.short_description = current.priority.getDisplayValue() + ' - ' + previous.short_description;
	
})(current, previous);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Robbie
Kilo Patron
Kilo Patron

Hi @rmaroti,

 

Can I ask why you/the business need to display and prepend the priority to the Short Description?

May I suggest you ensure the 'Activities filter' is configured to display the Priority (and Urgency and Impact) field(s). Out of box, whenever the fields in the Activities filter are updated, the activity field will display the old value and the new value. 

 

To help others (or for one-to-one direct help), please mark this response as correct and helpful.

 

Thanks, 

Robbie