- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2018 12:06 AM
I have mentioned coalesce in two fields and it isn't consider either one in each condition
Below i have mentioned the script
Where the insert takes duplicate values..
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
var gr=new GlideRecord('cmdb_ci_appl');
gr.query();
while(gr.next())
{
if( action=='update' && source.u_number == gr.u_number && source.u_name==gr.name && JSUtil.notNil(source.u_number))
//If application id and application name is same then data should update
{
ignore=false;
}
//If application id is empty and application name is present then it should insert
if( action=='insert' && source.u_number== "" && source.u_name!= gr.name)
{
//if application Id is empty and application name is already present then it should skip
ignore=false;
}
}
})(source, map, log, target);
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2018 12:27 AM
Hello Subhanand,
'Coalesce' field is used to create unique record in table.
If you make coalesce true for both fields, then it will take field1 && field2 to create unique record.
In your case it will consider unique values of 'name' and 'u_number' to create record.
So that modify your script accordingly.
Thanks & regards,
Vaijanath Shintre

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2018 12:27 AM
Hello Subhanand,
'Coalesce' field is used to create unique record in table.
If you make coalesce true for both fields, then it will take field1 && field2 to create unique record.
In your case it will consider unique values of 'name' and 'u_number' to create record.
So that modify your script accordingly.
Thanks & regards,
Vaijanath Shintre
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2018 01:14 AM
then how can i solve these issues
//If application id and application name is same then data should update
//If application id is empty and application name is present then it should insert
//if application Id is empty and application name is already present then it should skip
Becoz i need both of them to check for existing fields ,if there are any duplicates it inserts even i used coalesce and the script to check the condition
It didnt work can i know y?