How to write script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2025 09:32 PM
Create department field on incident table ,choices is
IT
Amin
2)create field as user -reference (sys_user)table
If some one select department IT then all IT related uses are aviator in user field same like admin.
how to write script for this scenario in ServiceNow?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2025 05:02 AM
Hi @MohanDegala
There's no need to write a script; you can make it dependent, similar to how the Caller field is dependent on the Company field. Likewise, you can set it up the same way. You can refer to the example of Assignment Group and Assigned To for guidance.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2025 06:39 AM
Thanks for responding but I know that way, I want to achieve this through script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2025 06:45 AM
Hi @MohanDegala ,
If you are using a choice field for Department, then you need to use an advanced reference qualifier in User field
To achieve this, you need to write scripts include:
Script Include: In this script, you will query the user table using GlideRecord based on the department selected in the choice field.
Script:
adavanced reference qualifier : javascript: new advancedReferenceQualifier().users(current.u_dept);
If you find my response helpful in resolving your query, please mark it as helpful.
Thank you!
Regards,
Keshav