Data Transfer between two tables using Transform Script

Neha Rani4
Tera Contributor
i want the  fields to synchronize between Hr profile table and Job table so that we have same data that is coming from quantum. 
in the transform map we need to add a tranform script to sync up the data with job table.
Below is the script that i have created on onStart :
    gs.info('Transform map @@@ ' +source.u_contract_num);
    var sync_data = new GlideRecord('sn_hr_core_job');
    sync_data.initialize();
    sync_data.u_contract_number = source.u_contract_num;
    sync_data.u_hr_status = source.u_assig_status_code;
    sync_data.user = source.u_name;
    gs.info('Transform map @@@ ' +source.u_contract_num);
    sync_data.insert();
 
Whenever I am Transform the data , it is not showing anything....maybe the script is not working as expected as i used log to check this and data is not geting in the desired table.
In the transform History ,it is not showing any import logs.
When i checked in the system logs it shows the message only which is "Transform map @@@ undefined".
 
1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hi @Neha Rani4 ,

The issue you are encountering seems to be the order of execution.
Try onBefore or onAfter-

Ensuring that the field we are accessing from source are properly mapped.

Now try the below code-

(function runTransformScript(source, map, log, target) {
    if (source.u_contract_num && source.u_assig_status_code && source.u_name) {
        var sync_data = new GlideRecord('sn_hr_core_job');
        sync_data.initialize();
        sync_data.u_contract_number = source.u_contract_num;
        sync_data.u_hr_status = source.u_assig_status_code;
        sync_data.user = source.u_name;
        sync_data.insert();
        gs.info('Transform map successful for contract number: ' + source.u_contract_num);
    } else {
        gs.error('Source fields are undefined. Contract number: ' + source.u_contract_num);
    }
})(source, map, log, target);

 

If my response has resolved your query, please consider giving it a thumbs up ‌‌ and marking it as the correct answer‌‌!

 

Thanks & Regards,

Sanjay Kumar

View solution in original post

8 REPLIES 8

AshishKM
Kilo Patron
Kilo Patron

Hi @Neha Rani4 , 

This code has 2 gs.info() with same message .. change it with different  and test which is one executing ... 

and based on output ..source.u_contract_num this is undefined, check the stage table values for this column. 

 

gs.info('Transform map @@@ 1' +source.u_contract_num);

....

....

gs.info('Transform map @@@ 2' +source.u_contract_num);

 

-Thanks,

AshishKM


Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution

Hi @AshishKM 

I have checked ,first gs.info() is working but the second one is not.

and the stage value is u_contract_num is this only but still showing undefined.

Thank you.

Community Alums
Not applicable

I think it might related to application scope. Your transform map is under Global scope?? Do you see any write operation entries in application restricted caller access from Global to HR scope with 'requested' status? if yes just change the status to grant the access and try.

Community Alums
Not applicable

Hi @Neha Rani4 ,

The issue you are encountering seems to be the order of execution.
Try onBefore or onAfter-

Ensuring that the field we are accessing from source are properly mapped.

Now try the below code-

(function runTransformScript(source, map, log, target) {
    if (source.u_contract_num && source.u_assig_status_code && source.u_name) {
        var sync_data = new GlideRecord('sn_hr_core_job');
        sync_data.initialize();
        sync_data.u_contract_number = source.u_contract_num;
        sync_data.u_hr_status = source.u_assig_status_code;
        sync_data.user = source.u_name;
        sync_data.insert();
        gs.info('Transform map successful for contract number: ' + source.u_contract_num);
    } else {
        gs.error('Source fields are undefined. Contract number: ' + source.u_contract_num);
    }
})(source, map, log, target);

 

If my response has resolved your query, please consider giving it a thumbs up ‌‌ and marking it as the correct answer‌‌!

 

Thanks & Regards,

Sanjay Kumar