Set subcategory based on category in script

gnunez
Kilo Guru

Hello,

I want to see if there is a way to set a subcategory based on a category in the script of a record producer. I am newbie when it comes to scripting so any help is greatly appreciated!

I want something like:

if current.category = "Software & Web Applications" then current.subcategory = "Code42";

Thanks,

Grace

9 REPLIES 9

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Grace,



Just curious on why you want to update this via record producer script. Do you want to update the values based on producer variable input? If not then this can go as part of the Business rule on the target table.


Hi Pradeep,



I am trying to update on a record producer because we need it to create an incident. Currently there are two categories: project and software & web applications and another variable for subcategory. The categories for project should be CS Upgrade 1, CS Upgrade 2, and CS Upgrade 3. For the software category the subcategory should be Code42, but right now all the subcategories show regardless of the category chosen. What I am trying to do is if a user selects software as the category then for subcategory it should only show code42 as an option and vice versa for project. I wasn't sure how to do this so I thought it'd be easier to script it for the software category.




Hope that made sense?


Got it. This can be done via dependent field at the field dictionary level. Please refer the below video and let me know if you are blocked.


https://www.youtube.com/watch?v=vBpu7B3nDwQ&t=1s


I don't think the video would apply to my scenario because I only want to add those fields for this specific form not all record producer/incident form. Or am I not understanding correctly?