- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2016 04:28 AM
During importing I need to update user name based on it's country and currency.. how should i add multiple conditions?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2016 05:06 AM
Thank you for the clarification. I wasn't aware the data was being imported in to another table. I'm going to assume you have fields on your sys_user table called u_country and u_currency. You can adjust the field names as necessary. I'm also going to assume the import set field name is 'u_name' - again, adjust the script below as needed.
Put something like this in the script field of your transform map.
var user = new GlideRecord('sys_user');
user.addQuery('name', source.u_name);
user.addQuery('u_currency', source.u_currency);
user.addQuery('u_country', source.u_country);
user.query();
if (user.next()) {
var target.u_user = user.getValue('sys_id');
// User was found with name, currency, and country
} else {
// user was not found with name, currency, and country
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2016 04:41 AM
Is the country and currency in the import set data or are you asking how to query it from the existing user record (if there is one)?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2016 04:47 AM
No it's not in import set data.. I need to query from the existing user record.
Let me explain , i have this record in my import - ABC_USER USA USD. (I have multiple records with user name "ABC_USER" but there countries are different.)
So i have split these and stored them in array,. Now i want, to search the user table with User "ABC_USER", if found then it should search for the user country & currency, if country and currency is US and USD, then it should set the target user as "ABC_USER".

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2016 04:53 AM
Can you just use the coalesce feature to match the record based on those three field criteria?
Using the Coalesce Field - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2016 05:02 AM
No i cannot
I don't have records from user table in my excel sheet. As i told you earlier.
i have this record in my excel - ABC_USER USA USD where ABC_USER(User name from user table) USA(Country) USD(Currency)
So i have split them into three parts which is User name + Country + Currency and i have stored these three values separately in an array..
Now i want my script to match the user first , if that user is found , then check for his country and currency.., If country and currency is US and USD respectively.. Then set that particular user to my target table.
Because as i have told you.. there are almost 100 users with name ABC_USER in system, so i need to differentiate if from country and currency.