Table, Import Sets, Transform Maps & Scripts

Ronald_T
Mega Contributor

Hello All.

I've been asked to:

1. Create a table that will show a list of records imported. It will have a unique ID# (7 digits), First Name, Last Name, Email, DOB, Zip code.

I've created the table (after a few tries - very new to this) and was able to import the data (auto map matching fields), however I need to condense the First and Last name fields into one field for 'First Name Last Name'.

2. Afterwards, I need to create Modules for Create New, Open, Closed and All.

                            When creating a new Incident, I want to be able to use the Opened For field and reference the list of records that I imported. Was able to create the modules, but the opened for field does not reference the First or Last name - it references the 'number' of the record - which is not correct.

3. Open incidents with a unique prefix. - able to use a specific prefix for the incidents. Probably the only thing that is working correctly.

I've created the modules for Create New, Open, Closed and All - but they are not working correctly - they do not show opened incidents because I cannot reference the table.

1. - I've tried creating a Transform Map that used matching fields and a script - found the script (was based on email, but I changed it) somewhere in the ServiceNow Community. I took a guess on how it should look. Does it have to be all script or can it be matching fields and a script?

When - On Start

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

  target.name=source.u_pat_first_name+' '+source.u_pat_last_name;

      return;

})(source, map, log, target);

Asking for help with #1 - then hopefully everything else will fall into place. I need it to all work in less than two weeks. No pressure right?

Thank you all, in advance, for any help you can provide me with.

4 REPLIES 4

Jon Barnes
Kilo Sage

I would say there are several ways to handle number 1. Here are my favorite 2 (2nd option is preferable).



1. create a script source field entry in your transform map, where you can access your first name and last name fields on the source record and return the concatenated value. Select your Full Name field on your target, and check the Script Source checkbox. In there, you can do something like this:



return source.u_first_name + " " + source.u_last_name;



2. This is the preferred option because it will catch the situation also if the first name and last name fields ever change in the future on the target table. Create a business rule that runs before insert/update, and only runs if First Name or Last Name changes (you can select those conditions in the business rule conditions tab.



then, select Advanced on your business rule, and in the script tab, write something like this:



current.u_name = current.u_first_name + " " + current.u_last_name;


Thanks Jon. The Second option did work the best. I have a question though. The table that I have setup. I would just like to show the full name and not the 'first name' and 'last name'   - can I delete them? Or can I create a new table (start from scratch - which is okay since there are few other things not working) with just the full name field and still be able to transform the two names into the one via the business rule or do I have to keep those columns or maybe I should just remove them from view.


Okay - I deleted all the records in my list table and tried again. Can't do it without the first and last name columns, but it does work if I remove those columns from view. A few other things work now as well. Thank you very much Jon!


sure glad to hear it worked. Yes, I agree, you need to keep the columns, but you can definitely hide them from view.