How would I go about creating a script to update some fields added in an incident template?

TrenaFritsche
Tera Expert

How would I go about creating a script to update some fields added in an incident template where the field is being changed to a different field. There are potentially thousands of templates and I would like to automate the search and find and replace various field names.  ie: a template has a custom field that is getting populated with a value, but that custom field is no longer being used and a different field will need to replace it.  If someone can just provide me tables to query that hold this template configuration, I should be able to figure out how to do it, but I am stuck when looking at a Template and see the field Template in sys_template is of type Template?  I'm missing something here.  Anyone know how to do this?

Thanks so much in advance!

Trena Fritsche

1 ACCEPTED SOLUTION

Hi,

Please use _next like:

while (gr._next()) {

See my edited code above.

This is because the template table actually have a column called: next, so then your next use variation is _next.

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

I haven't tested the "get" in-depth, but in my experience on these forums, 9/10 when a user has a problem with a record not retaining an update or something along those lines, it's because of using get instead of a query.

You're more than welcome to approach it any way you'd like, but I feel pretty good I gave you good initial code in my example. I'm really bet that you could literally just use what I gave you minus a few substitutions for 'old_field' and 'new_field, etc. and it would work fine.

Please mark reply as Helpful, if applicable. Thanks!

Take care!


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