Copy list type field from problem to change via Ui action not working

raju51
Tera Contributor

OOTB Create Normal Change copies field from problem to change for string type fields but does not copy custom list type field values from problem to change custom list type fields.

Script:

(function(current, previous, gs, action) {
// var affectedountries = current.getValue.u_affected_countries;
var changeRequest = ChangeRequest.newNormal();
changeRequest.setValue("short_description", current.short_description);
changeRequest.setValue("description", current.description);
changeRequest.setValue("cmdb_ci", current.cmdb_ci);

changeRequest.u_affected_countries = current.u_affected_countries; // not copying
changeRequest.u_affected_countries = current.u_affected_countries.toString(); // not copying

changeRequest.u_affected_countries = current.getDisplayValue('u_affected_countries'); // not copying
changeRequest.setValue("urgency", current.urgency);
changeRequest.setValue("impact", current.impact);

if (changeRequest.hasValidChoice('priority', current.priority))
changeRequest.setValue("priority", current.priority);
changeRequest.setValue("sys_domain", current.sys_domain);
changeRequest.setValue("company", current.company);
changeRequest.insert();

current.rfc = changeRequest.getGlideRecord().getUniqueValue();
current.update();
gs.addInfoMessage(gs.getMessage("Change {0} created", changeRequest.getValue("number")));
action.setRedirectURL(changeRequest.getGlideRecord());
action.setReturnURL(current);

})(current, previous, gs, action);

 

 

1 ACCEPTED SOLUTION

Aman Kumar S
Kilo Patron

Hi @raju51 ,

Change those fields as:

changeRequest.setValue("u_affected_countries", current.getValue("u_affected_countries")); 

 

Best Regards
Aman Kumar

View solution in original post

1 REPLY 1

Aman Kumar S
Kilo Patron

Hi @raju51 ,

Change those fields as:

changeRequest.setValue("u_affected_countries", current.getValue("u_affected_countries")); 

 

Best Regards
Aman Kumar