
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2016 07:03 AM
Hi Guys,
I have a transform map written to avoid duplicate records..i.e no 2 records can have same values. below is the script..I am not able to ignore duplicates,,am I missin something//?
/**
* For variables go to: http://wiki.service-now.com/index.php?title=Import_Sets_portal
**/
var bus=source.u_business.trim();
var grp=source.u_assignment_group.trim();
var country=source.u_country1.trim();
var Region=source.u_region.trim();
var value=source.u_language.trim();
var sched=source.u_schedule.trim();
var queryString="";
var flag=false;
var countryflag= null;
if(source.u_active=='FALSE'){
target.u_active=false;
}
/*Mapping business*/
if(bus==""||bus==null||bus==undefined){
bus=null;
target.u_business=null;
gs.log( " L1 Data Update business is empty " + bus );
}
else{
queryString ="u_active=true^u_type=GE Business";
var ga=new GlideRecord('core_company');
ga.addEncodedQuery(queryString);
ga.addQuery('name',bus);
ga.query();
if(ga.next())
{
//gs.log('502115929 L1 Data Update the business4'+bus);
bus=ga.sys_id;
if(target.u_business!=ga.sys_id){
target.u_business=ga.sys_id;
}
else{
gs.log('L1 Data Update Bus same4'+target.u_business+'and'+source.u_business+'both are same');
}
}
else
{
flag = true;
gs.log(' L1 Data Update the business4'+bus+'is not a valid one4 , row ignored!');
}
}
/*Mapping assignmnet group */
queryString="";
if((grp==""||grp==null||grp==undefined)){
flag = true;
gs.log( " L1 Data Update Group is empty, row ignored! " + grp );
}
else{
var ga1=new GlideRecord('sys_user_group');
ga1.addQuery('active',true);
ga1.addQuery('name',grp);
ga1.query();
if(ga1.next())
{
if(target.u_assignment_group!=ga1.sys_id){
target.u_assignment_group=ga1.sys_id;
}
else{
gs.log('L1 Data Update Bus same4'+target.u_assignment_group+'and'+source.u_assignment_group+'both are same');
}
}
else
{
flag = true;
gs.log(' L1 Data Update the AG4'+grp+'is not a valid one4, row ignored! ');
}
}
/*Mapping schedule*/
if(Region==""||Region==null||Region==undefined){
flag = true;
gs.log( " L1 Data Update Region is empty, row ignored! " + Region );
}
else{
var ga2=new GlideRecord('cmn_location');
ga2.addQuery('active',true);
ga2.addQuery('u_location_type','Region');
//ga2.addQuery('country',country);
ga2.addQuery('u_region',Region);
ga2.query();
if(ga2.next())
{
if((country==""||country==null||country==undefined)){
gs.log(' L1 Data Update the country '+country+'is empty one4');
target.u_country1=null;
}
else{
gs.log('SDLC11204522'+country);
//queryString="u_location_type=Country^u_region=EMEA^country=Iran";
var ga5=new GlideRecord('cmn_location');
ga5.addQuery('active',true);
//u_location_type=Country
//ga5.addEncodedQuery(queryString);
ga5.addQuery('u_location_type','Country');
ga5.addQuery('country',country);
ga5.addQuery('u_region',Region);
ga5.query();
if(ga5.next()){
if(target.u_country1!=ga5.sys_id){
target.u_country1=ga5.sys_id;
}
else{
gs.log('L1 Data Update Bus same4'+target.u_country1+'and'+source.u_country1+'both are same');
}
countryflag = ga5.sys_id;
}
else{
flag = true;
gs.log(' L1 Data Update the country '+country+'is not a valid one4, row ignored!');
}
}
if(target.u_region!=ga2.sys_id){
target.u_region=ga2.sys_id;
}
else{
gs.log('L1 Data Update Bus same4'+target.u_region+'and'+source.u_region+'both are same');
}
}
else
{
flag = true;
gs.log(' L1 Data Update the country '+country+' and region '+Region+'is not a valid one4, row ignored!');
}
}
queryString = "name=u_l1_helpdesk_routing^element=u_language^inactive=false";
if(value==""||value==null||value==undefined){
value=null;
target.u_language=null;
gs.log( " L1 Data Update Language is empty" + value );
}
else{
var ga3=new GlideRecord('sys_choice');
ga3.addEncodedQuery(queryString);
ga3.addQuery('value',value);
ga3.query();
if(ga3.next())
{
if(target.u_language!=ga3.value){
target.u_language=ga3.value;
}
else{
gs.log('L1 Data Update Bus same4'+target.u_language+'and'+source.u_language+'both are same');
}
}
else
{
flag = true;
gs.log(' L1 Data Update the Language'+value+'is not a valid one4, row ignored!');
}
}
if(!flag){
var gr = new GlideRecord("u_l1_helpdesk_routing");
gr.addQuery("u_language", value);
gr.addQuery("u_active", 'true');
gr.addQuery("u_business", bus);
gr.addQuery("u_region", ga2.sys_id);
gr.addQuery("u_country1", countryflag);
gr.query();
if (gr.next()) {
flag = true;
gs.log(' L1 Data Update already exists in the table , row ignored! '+gr.u_l1_helpdesk_routing_id);
}
}
gs.log( " L1 Data Update \nAssignment group:'" + grp +"'\n Business: '"+bus+"' \ncountry: '"+country+"' \nRegion: '"+Region+"' \nLanguage: '"+value+"' \nRow ignored: '"+flag+"' ");
if(flag)
ignore = true;
Harish
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2016 04:35 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2016 07:05 AM
Hi Harish,
It seems to be quite a length Run Script of Transform Map, first step of Transform map is to find out the Coalesce field, did you try that route?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2016 07:08 AM
yep I tried coalesce. It creates new record with different routing ID, but we don wan same values for another record.
Harish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-28-2016 04:35 AM
Issue resoved, Problem was with display value
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-03-2022 02:27 AM
Hi Harish
i am getting same issue can you help me to resolve the issue