Get values from template

Vinay49
Tera Expert

Hi 

we have a requirement to update the template values through the script.

 

var grTemplate = new GlideRecord('sys_template');
        grTemplate.addQuery('sys_id','2e43edbfdb155428a497574b6896199c');
        grTemplate.query();
        if(grTemplate._next())
            {
                var string = grTemplate.template.toString();
    
// how can we proceed here to get the value of field  & update the value with new.
               
            }
15 REPLIES 15

Hi Naveen,

Thanks for your reply,
with your script,  one more field value(state is InProgress) is adding like below.

Vinay49_0-1707395643135.png



But, my requirement is, I want to make the state value from InProgress(2) to pending(3) for this template.

Change your choice as per your requirement like "state=3"

Regards,

Naveen G N



please mark correct if you find it correct

Hi Naveen,

let assume i have one template which has already created in sys_template table with values like below.

Vinay49_0-1707396559150.png

 

Now I want to change the state & channel from phone & pending respectively.


 



Amit Verma
Kilo Patron
Kilo Patron

Hi @Vinay49

 

Can you try with the below code :

 

 

var grTemplate = new GlideRecord('sys_template');
grTemplate.addQuery('sys_id','56e62ccbc611227500adb083f968a484'); // Replace with Sys_id of your template record
grTemplate.query();
if(grTemplate._next())
{
                grTemplate.auto_provisioning_user= 'true'; // Change the field name as per your field
                grTemplate.update_user_record_upon_each_login = 'true'; // Change the field name as per your field
                grTemplate.update();
 }

 

 

Thanks & Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

Hi Amit,

Thanks for the update. It is not working