Get values from template
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 02:36 AM
Hi
we have a requirement to update the template values through the script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 04:09 AM
Hi @Vinay49
Sorry your screen shot is not clear to me.
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
02-08-2024 04:13 AM
Hi Atul,
can you check here. I want to update the below fields(highlighted in yellow) through script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 02:56 AM
If you want to update a template via template you use the below code
GlideTemplate.get(template.sys_id).apply(GlideRecord)
Please mark correct if you find it useful.
Regards,
Naveen G N
ServiceNow Developer,
Aelum Consulting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 03:06 AM
Hi Naveen,
Thanks for your reply. can you elaborate more on it. I want to update the below fields(highlighted in yellow) through script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 04:11 AM
Can you try below code?
var gr = new GlideRecord("sys_template");
if(gr.get("acd87481d7930200f2d224837e6103f3")){
gs.print(gr.template)
var temp = gr.template+"^state=2"
gr.template = temp;
gr.update()
}
Regards,
Naveen G N
please mark correct if you find it correct