How to auto set the category and subcategory on RITM generated through Order Guide based on the catalog item ordered?

Diksha Tiwari1
Giga Expert

Hello Developers,

 

I have a client requirement where the category and subcategory on RITM generated through the order guide is auto-populated from the category choice based on the catalog item ordered.

I have tried to achieve this through after BR with Insert operation with below script but the fields are not getting map.In the below script, I have added the sys_ids of the catalog item and have written this on requested item table.

find_real_file.png

find_real_file.png

Can anyone help me to know the error and how to achieve this?

1 ACCEPTED SOLUTION

Thank you Harsh!

The solution provided by you works fine, however, we also focus to follow recommended practice only to deliver the solution and its recommended to avoid the current.update() within any business rule as its use can cause performance issues. 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0715782#:~:text=The%20current...

However, I managed to achieve the requirement using before insert BR with the same script and it worked for me.

I would appreciate the time taken by you to help me providing the solution.

Thanks,

Diksha

 

View solution in original post

4 REPLIES 4

Harish KM
Kilo Patron
Kilo Patron

Hi Have you checked "cascade variables" field on Order Guide to true? This will pass variable values to your catalog item variables.

Regards
Harish

yes its set to true!

Hi you can pass the value like this

    current.setValue('category','network'); // make sure you have correct choice value
    current.update(); // after BR must have current.update to update the choice value which is missing in your code

Regards
Harish

Thank you Harsh!

The solution provided by you works fine, however, we also focus to follow recommended practice only to deliver the solution and its recommended to avoid the current.update() within any business rule as its use can cause performance issues. 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0715782#:~:text=The%20current...

However, I managed to achieve the requirement using before insert BR with the same script and it worked for me.

I would appreciate the time taken by you to help me providing the solution.

Thanks,

Diksha