The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Help Transform Field map script not working correctly

E_19
Giga Expert

Hi All,

I hope someone can help me.

I have a transform field map script that is not working correct. What I am trying to do is iterate though the source kunden number and for all matches that are found in core company table   the corresponding sys_id is added to u_company field but the script iterates and has the same company sys id for every record. In the log file it records same sys_id but also each unique kunden number.

Need to add the field is a reference field and the Referenced value field name: u_company

Any idea why it is not return the unique sys_id for each record?

answer = (function transformEntry(source) {

  var gr1 = new GlideRecord("core_company");

  gr1.addQuery("u_company",source.u_kundennr_.toString());

  gr1.query();

  if(gr1.next()){

  target.u_company = gr1.sys_id;

  }

  gs.log("Kundennummer: " + source.u_kundennr_);

  gs.log("sys_id von ?: " + gr1.sys_id);

  return ""; // return the value to be put into the target field

})(source);

Many Thanks,

Ellie

1 ACCEPTED SOLUTION

can you try like this


  var gr1 = new GlideRecord("core_company");


  gr1.addQuery("nr",source.u_kundennr_.toString());


  gr1.query();


  if(gr1.next()){


  target.u_company = gr1.sys_id;


// put your logs here


  }


View solution in original post

10 REPLIES 10

E_19
Giga Expert

All,



I want to add something but I might open a separate post.



The load will be a scheduled nightly load using the updated source file.



If users are removed form the file I need to set their records to u_active = false.



How can I compare the load and find the records that are missing to what is currently in the table?



Any suggestion or code sample welcome



Many Thanks,


Ellie