Covert GB into MB using transform script

ChrisSN
Tera Contributor

I have an excel sheet that has the ram in GB and I need it covered to MB on the computer cmdb_ci_computer table. The title on the excel is "DEVICE_MEMORY" and the values show as "10GB". I tried the script below but no luck, any advice? 

 

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {

 

var deviceMemoryInt = parseInt(source.u_device_memory, 10);

 

if (!isNaN(deviceMemoryInt)) {

 

target.ram = deviceMemoryInt * 1024;

}
})(source, map, log, target);

1 ACCEPTED SOLUTION

Do you have the ram field on your field map?  If so that maybe whats causing the issue with your script.

 

It would probably be easier to use a field mapping script.  So add a field mapping and check the "Use source script" and use that script to do the calculation and then just return the value.

View solution in original post

6 REPLIES 6

Do you have the ram field on your field map?  If so that maybe whats causing the issue with your script.

 

It would probably be easier to use a field mapping script.  So add a field mapping and check the "Use source script" and use that script to do the calculation and then just return the value.

ChrisSN
Tera Contributor

Yes, removing the field from the field map resolved the issue, thank you!