OnAfter or Field map script transform script help needed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2017 08:12 AM
Hi All,
Can someone advise on how I should approach the below requirement:
I have load a list of companies into core_company table.
They all have a customer id, debit group id which is often the same but not always
After each load I would like to run an onAfter script to take the debit group id and find the matching name in the core_compnay table
and add this to the reference field Parent.
comp id Parent field should result in Debit group id
100000 | xyz company | street 19 | London | UK | xyz company | 100000 | ||
100001 | abc Ltd | way 1 | Berlin | DE | abc Ltd | 100001 | ||
100004 | time Ltd | lane 2 | Zürich | CH | xyz company | 100000 | ||
100005 | now Ltd | road 3 | New York | USA | time ltd | 100004 |
Any suggestions greatly appreciated.
Thanks,
Ellie
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2017 09:50 AM
Hi Venkat,
I corrected the typos but as mentioned above script results in undefined:
I have added var pare to the script to get the name for each company and pass that into Parent field but it still results in undefined.
var gr = new GlideRecord('core_company'); | |
var pare = gr.getDisplayValue('name'); |
gr.addQuery('u_debitor_group',source.u_debitoren_gruppencode);
gr.query(); // Issue the query to the database to get all records
while (gr.next()) {
// add code here to process the incident record
target.parent = gr.pare;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2017 10:37 AM
it should be gr.sys_id like below. not gr.pare
target.parent = gr.sys_id.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2017 10:41 AM
you can ignore that I tried something but didn't work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2017 09:17 AM
Hi srnewbie, I had tried something similar and just tried your code but also resulted in undefined is enter into the Parent field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-11-2017 09:38 AM
what type of field is 'u_debitor_group' and 'u_debitoren_gruppencode', can you post a screen shot of parent field with resulted value?