OnAfter or Field map script transform script help needed

E_19
Giga Expert

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                

100000xyz companystreet 19LondonUKxyz company100000
100001abc Ltdway 1BerlinDEabc Ltd100001
100004time Ltdlane 2 ZürichCHxyz company100000
100005now Ltdroad 3New YorkUSAtime ltd100004

Any suggestions greatly appreciated.

Thanks,

Ellie

16 REPLIES 16

Hi Venkat,



I corrected the typos but as mentioned above script results in undefined:



Screen Shot 2017-04-11 at 17.12.34.png




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;  


  }


it should be gr.sys_id like below. not gr.pare


target.parent = gr.sys_id.


you can ignore that I tried something but didn't work


Hi srnewbie, I had tried something similar and just tried your code but also resulted in undefined is enter into the Parent field.


what type of field is 'u_debitor_group' and 'u_debitoren_gruppencode', can you post a screen shot of parent field with resulted value?