- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2022 12:23 AM
I have 2 fields which are of choice list, Now requirement is to copy one field values to another field and also by eliminating duplicates.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2022 06:48 AM
Hello @Hareesha,
Please run this script in your background script:
var project = new GlideRecord('your table name');
project.addNotNullQuery('second field'); //query to check if the second field has empty value
project.query();
while (project.next())
{
project.second field = project.first field;
project.update();
}
Please mark it as correct based on impact.
BR,
Nayan
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2022 07:04 AM
Hello,
Please use the below script in background or fix script. I have already tried on my PDI works fine. Correctly replace the fieldname. Assuming you will copy values from fieldname1 to fieldname2. Also I hope fieldname1 and fieldname2 are referring to the same table
var gr = new GlideRecord('pm_project');
gr.addEncodedQuery('addyourquery');
gr.query();
while (gr.next()) {
var value = [];
value = gr.replacefieldname1.split(',');
value.push(gr.replacefieldname2.split(','));
var uniqueValue = new ArrayUtil().unique(value);
gr.replacefieldname2 = uniqueValue.toString();
gr.update();
}
Please mark my answer as correct based on Impact.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2022 01:10 AM
Hello,
You can select table and another field like below, it should work easily.
Regards,
Musab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2022 01:17 AM
Hi Rasheed, I can see only one field called choice under choice list specification

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2022 01:54 AM
Can you share screenshot of your form please ?
Regards,
Musab
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2022 06:26 AM - edited 11-30-2022 06:33 AM
Hi Rasheed my requirement is not to get same field values from another table. My requirement is i have 2 fields in project form and there are some existing records. Now they are asking me to remove one field and copy whatever selected data from dropdown in the field to another field by eliminating duplicates as second field is also having some data. Both fields are of type list and same field values.