Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Importing templates for a table - How do I get the fields to map?

Travers M
Mega Guru

OK, so I have this nice Excel sheet that has approximately 250 records that I need to turn into templates for Facilities Requests.   I could do them by hand, but there has to be an easier way.     In my transform map, if I select the target table as Facilities Request then I'll just get a ton of records but have the fields I need but if I set the target table as sys_template then I don't have the fields I need to map.   I hope this is something silly I'm not thinking of or I just missed something easy.   If anyone has done something similar, I'd love to hear how you pulled it off.

5 REPLIES 5

frankh_
Giga Expert

I was hoping someone else would answer sooner - the field names and values are stored in the field "template" which is of the type "TemplateValue" - this field is essentially an array.   I did this once before - basically I created a demo template and then printed the array to get the structure and then wrote a transform map to load up the array.   Unfortunately I do not have access to the instance where I did this - I will try and create a sample script again, but I really have dig in to the cobwebs.


Thanks for that.   I'm not sure I follow it 100% but it has at least ruled out I'm not missing something obvious.


Travers - I had a chance to look - it is a little less complicated than I originally indicated.   The template field is actually just a string field - it looks something like this:


cpu_count=1^fault_count=0^os=Linux Red Hat^cpu_type=Intel^install_status=1^name=Set host name here...^operational_status=1^cpu_speed=2800^ram=2048^disk_space=40^EQ



in order to create that string you are going to have write a script that parses all your fields in to equivalent strings - depending on how consistent your data is this will be easy or hard.   So the line in your transform map script could look something like this (assuming a high degree of uniformity):



target.template = 'facility_name=' + source.facility_name + '^room_number=' + source.room_number + '^EQ'



Of course setting fields like table and Display Name appropriately based on your algorithm.   I am not familiar with the facility request table so it is hard to write much more than that.   Did this explanation make any sense?



That does make sense, thank you.   My fields I have to move over are location, detailed description, category and sub category. It's not overly advanced as far as the fields I need, but this should help me get where I need to be.