Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Transform Map issue

Debasis Pati
Tera Guru

Hello All,
I have created a transform map for group table created the name field as coelesce and also transformed it it successfully created records everything is fine leaving one thing.
there is a type field which is a list collector in sys_user_group table when i transformed the excel sheet it created some duplicate values in "sys_user_group_type" as incident,change,request etc we already have incident,change,request wtc out of box values how this duplicate value creation can be avoided also it should map the existing correct group types.
one row example of my excel sheet.

Name   Type   Line Vendor/managerDescription    Group email
Testincident,changeDebasistest descriptiontest@group.com

@Ankur Bawiskar  any suggestions?


@

25 REPLIES 25

@Debasis Pati 

then handle using transform onBefore script

Remove the field map for that Type field

something like this

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

	// your existing logic


	// handle list logic here
    var arr = [];
    var incomingType = source.u_type.toString();
    var gr = new GlideRecord("sys_user_group_type");
    gr.addQuery("name", "IN", incomingType);
    gr.query();
    while (gr.next()) {
        arr.push(gr.getUniqueValue());
    }
    target.type = arr.toString();

})(source, map, log, target);

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hello @Ankur Bawiskar ,
i tried the on before script

The type filed in group records are now blank no values in it.
Note:My group types contains multiple values like incident,change,problem and in some records only incident below is example:

Name   Type   Line Vendor/managerDescription    Group email
Testincident,changeDebasistest descriptiontest@group.com

@Debasis Pati 

did you debug what came in that array?

basically it will search that group type table with those names

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

    // your existing logic


    // handle list logic here
    var arr = [];
    var incomingType = source.u_type.toString();
    var gr = new GlideRecord("sys_user_group_type");
    gr.addQuery("name", "IN", incomingType);
    gr.query();
    while (gr.next()) {
        arr.push(gr.getUniqueValue());
    }
    gs.info("Type array is" + arr.toString());
	
    target.type = arr.toString();

})(source, map, log, target);

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hello @Ankur Bawiskar 

the array log is coming blank but i checked the incoming type it is coming like below for different different records
incident.request,problem,chnage
incident,request

change,problem

like the above that's why i think its not finding individual type records in the add query

 

@Debasis Pati 

the addQuery is using IN operator so it should be able to search in the name field

Did you try searching directly in group type table if those records are present?

share screenshots.

if they are then logic I shared will work for sure.

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader