How to get the value of template value type field

anushadande
Mega Contributor

Hi ,

 

As part of our requirement ,  need to check logged in user is member of assignment group or not which is present in standard change template.

can anyone please give me any idea "how to get the value of assignment group " which is present under change_request values in templates . Attaching screenshot 

 

Anyidea really helps alot

 

Regards

Anusha

1 ACCEPTED SOLUTION

Allen Andreas
Administrator
Administrator

Hi,

Not sure of your end result requirement here, but you can query the sys_template table for a specific sys_id (for example) and then look for the value of a specific entry on it. If you're doing this in the client, then you'd want to utilize GlideAjax to return that value back to your client from the server: https://community.servicenow.com/community?id=community_article&sys_id=9f7ce2e1dbd0dbc01dcaf3231f961...

In server side script, you could find value like this (EXAMPLE😞

var gr = new GlideRecord('sys_template');
gr.get('sys_id_of_template');
gs.info('***Short Description from Template is: ' + gr.short_description);

Then if it equals what you're wanting it to do, you could apply the template through script as well with:

https://servicenowguru.com/system-definition/advanced-templates/

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

5 REPLIES 5

Allen Andreas
Administrator
Administrator

Hi,

Not sure of your end result requirement here, but you can query the sys_template table for a specific sys_id (for example) and then look for the value of a specific entry on it. If you're doing this in the client, then you'd want to utilize GlideAjax to return that value back to your client from the server: https://community.servicenow.com/community?id=community_article&sys_id=9f7ce2e1dbd0dbc01dcaf3231f961...

In server side script, you could find value like this (EXAMPLE😞

var gr = new GlideRecord('sys_template');
gr.get('sys_id_of_template');
gs.info('***Short Description from Template is: ' + gr.short_description);

Then if it equals what you're wanting it to do, you could apply the template through script as well with:

https://servicenowguru.com/system-definition/advanced-templates/

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Hi Allen,

Thanks for the Reply. 

But assignment group which is present under change_request (Tempalte_Value type) . So, not able to pull the assignment group value like short_description as this field is on the form itself.

Please see attached docs and suggest me how to get the value of asignment group. 

 

Regards

Anusha

Ankur Bawiskar
Tera Patron
Tera Patron

@anushadande 

this sample script should help you get the value

Enhance it as per your requirement

var templateValue = "active=true^assignment_group=555aed3fc0a8016600657c7b0ddc6e97^short_description=hello";
templateValue = templateValue.split("assignment_group=")[1];
var group = templateValue.substring(0,32);
gs.info(group);

Output:

find_real_file.png

Regards
Ankur

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

Hi ANkur,

 

Can you please advise how you were able to get the field name and its respective values.