Iam Creatin Incident Record it is a Parent Record to chage the category field automatically chage to child incident categroy

nani2
Kilo Contributor

Iam Creatin Incident Record it is a Parent Record to chage the category field automatically chage to child incident categroy

5 REPLIES 5

OlaN
Giga Sage
Giga Sage

Hi,

So it looks like you want to change a category of a specific INC based of the value from the parent INC.

Why are you scripting this? You could just change/set the value directly as an admin.

Mohit Kaushik
Mega Sage
Mega Sage

Hi There,

Please explain your query properly. You want to change the category of child incident as parent incident upon creation of child incident?

If yes, then you need to write a Business Rule on your child incident with below conditions:

When: before, insert.

advanced: true

script:

current.category = parent_incident.category;

If not, please clarify the use case properly and share the code in comments not the screenshot.

 

Please mark this as correct and helpful if it resolved the query or lead you in right direction.

Thanks,
Mohit Kaushik
Community Rising Star 2022

Thanks,
Mohit Kaushik
ServiceNow MVP (2023-2025)

Imran Ahmad1
Kilo Guru

Hii @nani 

 

Copy and paste the this tested code you will achieve your requirement for sure:-

 

Regards,

Imran Ahmad

 

Please Mark as Correct Answer:-

Please Mark as Helpful:-

 

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

var child = new GlideRecord("incident");
	child.addActiveQuery();
	child.addQuery("parent_incident",current.sys_id);
	child.query();
	while(child.next()){
		child.category = current.category;
		child.update();
	}
})(current, previous);

find_real_file.png

 

find_real_file.png

 

 

If Correct Mark as Correct:-

Please Mark as Helpful:-

nani2
Kilo Contributor

its not working in line number 6 error