reference field value is populating undefined via field script of transform map after upgrade to SanDiego

Ulka1
Tera Contributor

Hello Expertise,

We have a reference field 'Opened for' and we are setting this field value as null when one other field's value (field name XYZ) is null using field script of transform map.  before upgrade this was working fine but our instance is upgraded from Quebec to San Diego version we are facing the below issue.

Undefined value is auto populating  for the reference field 'Opened for'  instead of null when we import the data using the transform map. Even after updating  and saving the value of reference field 'Opened for' with the correct user, later when we import the data again the reference field 'Opened for' showing undefined value again on the case.

Did any one faced this type of issue earlier?  If any body knows about this issue then please let us know.

 

Thanks,

Ulka

 

 

13 REPLIES 13

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Share the field map script or transform script which you are using along with screenshots

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

Sorry for responding late.

Below is the field script for the 'Opened for' field in the transform map.

answer = (function transformEntry(source) {
var lineofbusiness = source.u_line_of_business;
//updated code
if(source.u_hr_business_partner){
var userName = '';
var gr = new GlideRecord('sys_user');
gr.addQuery('email', source.u_hr_business_partner);
gr.query();
if(gr.next()){

 

userName = gr.sys_id;

 

}

if((lineofbusiness == 'A') || (lineofbusiness == 'B')){

if(source.u_hr_business_partner == ''){
if (action == 'insert') {
target.opened_for = '';
target.assignment_group.setDisplayValue('HR_Group1');
target.assigned_to = '';
}
return target.opened_for = '';

}
else {
if(source.u_hr_business_partner != ''){

if (action == 'insert') {

target.opened_for = source.u_hr_business_partner;
target.assignment_group.setDisplayValue('HR_Group2');
target.assigned_to = '';

}

return target.opened_for = source.u_hr_business_partner;
}

}
}

 

else {
if(source.u_hr_business_partner == ''){

if (action == 'insert') {
target.opened_for = '';
target.assignment_group.setDisplayValue('HR_Group3');
target.assigned_to = '';
}
return target.opened_for = '';

}

else {
if(source.u_hr_business_partner != ''){
if (action == 'insert') {
target.assignment_group.setDisplayValue('HR_Group4');
target.assigned_to = userName;
}
}

}
return target.opened_for = source.u_hr_business_partner;
}
target.assigned_to = userName;
}
})(source);

 

Note: we have a issue when HRBP is blank in excel sheet (Which we are using for load) then it will set Opened for as undefined, assignment group & assigned to as blank. If assigned to person will save/update the opened for field , assignment group and assigned to then in next load system will override those values and opened for field will be set as undefined again

 

 

Please let us know if have any solution to this issue.

 

Thanks,

Ulka

 

Hi,

so what debugging have you done so far?

which else of IF it evaluates?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

we have an issue in this if else loop. we have tried source.u_hr_business_partner.nil() as well but still we are getting opened for as undefined when we load the data. 

Actually we have daily 3x load and the saved value is also override in every load. 

Please help us to find the solution. 

if(source.u_hr_business_partner == ''){
if (action == 'insert') {
target.opened_for = '';
target.assignment_group.setDisplayValue('HR_Group1');
target.assigned_to = '';
}
return target.opened_for = '';

}

Thanks,

Jyoti 

Hi Ankur,

1.we have checked by inserting the gs.logs/gs.info messages in the if and else loop but log messages are not showing in system logs.

2.Then we tried to see the reason why 'Opened for' field valus is getting override when we imports other records by setting 'Field Watcher' for the 'Opended for' field but field watcher shown the only acls which are workinhg on the 'Opened for' field.

which else of IF it evaluates?: The below else is working fine.

else {
if(source.u_hr_business_partner != ''){

if (action == 'insert') {

target.opened_for = source.u_hr_business_partner;
target.assignment_group.setDisplayValue('HR_Group2');
target.assigned_to = '';

}

return target.opened_for = source.u_hr_business_partner;
}

 

 

So we are facing issue for the below  if condition

 

if((lineofbusiness == 'A') || (lineofbusiness == 'B')){

if(source.u_hr_business_partner == ''){
if (action == 'insert') {
target.opened_for = '';      -->(here the system set value as 'undefinded' on the HR form when cases is created by importing excel sheet data)


target.assignment_group.setDisplayValue('HR_Group1');
target.assigned_to = '';
}
return target.opened_for = '';

 

 

If you need more information regarding this issue then let us know.

 

Thanks,

Ulka