How to carry over category and subcategory from incident to change in related list

ernestogome
Tera Contributor

Hi, I just wanna say that I am very new to Snow and I'm just getting to know the platform.

I got assigned the following task:

I would like the category and subcategory of incident to carry over to change records when a change is created from an incident record.

In the incident form, I have the change request related list in which I can submit a new change by clicking the New button. This button redirects me to sn_chg_model_ui_landing.do, not to the change_request.do page. How do I manage to carry over the cat and subcat from my incident? I know I can do it via params in the URL:

sysparm_query=^category=categorytest

But it doesn't work when I select the model from the sn_chg_model_ui_landing.do. Any help?




2 ACCEPTED SOLUTIONS

Bhavya11
Kilo Patron

Hi @ernestogome 

 

you can try with before Business rule to map the category and subcategory from incident to change but make sure the value of the category and subcategory of incident and also change is same.

 

if yes then try this way

 

Table: Change Request (change_request)

When: before

Insert: Checked

Condition: parent is not empty.

Bhavya11_0-1766984786767.png

 

Script:

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

var parentRec = current.parent.getRefRecord(); 
    
    if (parentRec.isValidRecord() && parentRec.getTableName() == 'incident') {
        // Copy the values
        current.category = parentRec.category;
        current.subcategory = parentRec.subcategory;
    }
})(current, previous);

 

If this information proves useful, kindly mark it as helpful or accepted solution.

 

Thanks,

BK

If this information proves useful, kindly mark it as helpful or accepted solution.

Thanks,
BK

View solution in original post

Ankur Bawiskar
Tera Patron

@ernestogome 

see when you click New button in related and when new CHG form is opened if INC sysId is there in URL

if yes then extract that and then query it in display business rule on change_request and use that to get category subcategory and set it on CHG

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

View solution in original post

6 REPLIES 6

Hello @ernestogome ,

Since you got the SysId, you can do a GlideAjax() call to the Server side and get the details.

Regards,
Najmuddin

SohamTipnis
Giga Guru

Hi @ernestogome,

 

Try to use the business rule for the change in category and subcategory; using the below actions will help you for the solution.

 

Table: Change Request (change_request)

When: before

Insert: Checked

Condition: parent is not empty.

 

If you find my answer useful, please mark it as Helpful and Correct ‌‌‌‌😊

 

Regards,

Soham Tipnis

ServiceNow Developer ||  Technical Consultant
LinkedIn: www.linkedin.com/in/sohamtipnis10