Update the work notes if the variable changes in SCTASK

sivaprince231
Giga Expert

If change the “request type” on the ticket, it should automatically update the work notes of SCTASK  to “request type has been changed”. 

Please help me with the Business rule

find_real_file.png

3 REPLIES 3

Voona Rohila
Kilo Patron
Kilo Patron

Hi siva

Write a Business rule/Client script Which will check the values of variables.

BR: Before update on sc_task

Condition: current.variables.changes() && current.request_item.cat_item.name == 'Catalog Item Name/sysid here'

Script:

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

    // Add your code here

current.work_notes = 'request type has been changed';

})(current, previous);

 

client script:

you can write onChange Catalog Client Script on that variable for your catalog item

1) Applies on CTASK's.

2) Script:

function onChange(control, oldValue, newValue, isLoading) {
	if (isLoading || newValue == '') {
		return;
	}
        if(oldValue != newValue)
{
	var str = 'Request type changed';
	g_form.setValue('work_notes', str);
	g_form.save();
}
}

 

Refernce links : https://community.servicenow.com/community?id=community_question&sys_id=ee019ba9db2f2090fb115583ca96...

https://community.servicenow.com/community?id=community_question&sys_id=746e4a82db2c201066f1d9d96896...

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

Prasad Pagar
Mega Sage

Hi @sivaprince231@gmail 

So you are going to keep variables editable on RITM? For e.g Request Type and people will change in manually during lifecycle of RITM?

Thank you
Prasad

Dan H
Tera Guru

Hi Siva,

I have tested in PDI:

Just change description to your field. You can use before or after.

find_real_file.png

 

and Script:

find_real_file.png

 

Please mark helpful or solved if it has helped you with your query