- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-06-2016 06:13 AM
I have user information which is being pulled in from our HR system. Everything is working fine, but they want to be able to update their information in ServiceNow independent of HR data. So, for instance, if you want to change your email address, phone or mobile number, you can do so, and the daily HR input will leave it alone. The proposed way of doing this is to have a script in the transform that says if employee.phone == "" then the source data is populated into the record. If there is anything in the field - leave it alone.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-06-2016 06:35 AM
Hi Shembop,
Create a field map with employee.phone as the target field. On the field map form, tick the checkbox 'Use Source Script' and then enter a source script like this:
if (target.phone == ''){
answer = source.u_phone;
}
This assumes 'phone' is the name of the field in your source file.
Jamie.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-06-2016 06:26 AM
User transform script by checking "Run script" check box and write the conditions in script area. Please go through Transform Map Scripts - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-06-2016 06:35 AM
Hi Shembop,
Create a field map with employee.phone as the target field. On the field map form, tick the checkbox 'Use Source Script' and then enter a source script like this:
if (target.phone == ''){
answer = source.u_phone;
}
This assumes 'phone' is the name of the field in your source file.
Jamie.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-06-2016 06:53 AM
Thank you Jamie, I will try this. We were using a much more involved script which looked to be working, but when I ran through the audit log, it ended up grabbing random phone numbers to plug in the blank fields.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-07-2016 06:36 AM
Unfortunately this didn't work. It works in making it so that an item has something in the field, it leaves it alone, but unfortunately the following is also true.
- If you take a record that has the number populated, and you clear the field, the next load it populates the field with the word undefined
- If you load a new record which has a mobile phone, it also loads the field with the word undefined
- If a record is updated that has no phone number in the import or the user record, it also loads the field with the word undefined
- New record with no phone number - same as above.