- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2017 07:37 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2017 08:52 AM
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
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2017 09:40 AM
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