Can we load the Data in the target table without field mapping through transform map runscript

Munna1
Tera Contributor

Hi Team,

Without using field mapping, I want to load the data in the target table with the transform map runscript. I am trying with this script but it is not working out.

 

var value = source.getValue('user_name');
    var grd = new GlideRecord('sys_user');
    grd.addQuery('user_name',value);
    grd.query();
    if(grd.next()){
        var emp = new GlideRecord('u_employee_profile');
        emp.initialize();
        emp.number=source.u_number;
        emp.user = source.u_user;        // Target user field is the Reference field 
        emp.state = source.u_state;      
        emp.start_date =source.u_start_date;      
        emp.end_date = source.u_end_date;
        emp.location = source.u_location;          // Target location field is the CHOICE FIELD
  emp.work_phone=source.u_work_phone;
        emp.insert();

    }
    else{
ignore = true;
}
1 REPLY 1

Community Alums
Not applicable

Hi @Munna1 ,

Can please make use of try cache block and write your code in it, will be helpful to understand what actual error is.

(function runTransformScript(source, target) {

try {

     // paste code here.

}

catch (e) {

// Log any error that occurs

gs.error('Error in Transform Script: ' + e.message);

}

})(source, target);