Data Load in Asset table

Sarah Bouil
Tera Expert

I have a AQCC Name(u_aqcc_name) List type field(it reference to u_aqcc table) in Asset table and it holds one or more AQCC Names data with comma(,) separated. if I load data thru Transform Maps, if the AQCC Name exist(ex: AQCCTest01) it should be updated and if the AQCC Name(ex: AQCCTest02) does not exist it should be ignore. I tried with below code but it is not working.

 

AQCC.png

 

(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
var isValidId = true;
var isMandatory = false;
if (!source.u_imp_aqcc_name.nil()) {
isMandatory = true;
}
if (isMandatory == false) {
if (source.u_imp_aqcc_name.nil()) {
ignore = true;
status_message = "Record has not been created due to blank value in AQCC Name column";
}
}
if (isMandatory == true) {
var aqccName= source.u_imp_aqcc_name;
isValidId = new VFdpdExport().isActiveValidId('u_aqcc', 'u_active=true^u_displayname=' + aqccName);
if (isValidId == false) {
ignore = true;
status_message = aqccName + " Record has not been created due to invalid value in AQCC Name column";
}
}
})(source, map, log, target);

It is always ignore the record and showing the message as 'Record has not been created due to invalid value in AQCC Name column'. I am suspecting the total AQCC Name consider as a one String(AQCCTest01, AQCCTest02) hence it's ignoring.

8 REPLIES 8

Anil Lande
Kilo Patron

Hi,

Please try below:

function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
var isValidId = true;
var isMandatory = false;
if (!source.u_imp_aqcc_name.nil()) {
isMandatory = true;
}
if (isMandatory == false) {
if (source.u_imp_aqcc_name.nil()) {
ignore = true;
status_message = "Record has not been created due to blank value in AQCC Name column";
}
}
if (isMandatory == true) {

var aqccName= source.u_imp_aqcc_name.split(',');
for (var i=0; i<aqccName.length;i++){
isValidId = new VFdpdExport().isActiveValidId('u_aqcc', 'u_active=true^u_displayname=' + aqccName[i].trim());
}
if (isValidId == false) {
ignore = true;
status_message = aqccName + " Record has not been created due to invalid value in AQCC Name column";
}
}
})(source, map, log, target);
Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

I tried with above code but the record is ignoring. AQCCTest01 record is exist in system so the record should be inserted. AQCCTest02 doesn't exist so it should be display a message the AQCCTest02 is not valid record so it ignore the record.

Hi,

Sorry your requirement is not clear, can you please explain in which table you are loading data and what all records should be updated in what condition?

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

I need to load data into Asset table. I have a custom field AQCC Name(u_aqcc_name) in Asset table which is reference to 'u_aqcc' table.

 

If the user populate correct data from excel sheet and which is exist in u_aqcc table it should be update in AQCC Name field in that corresponding row.

 

If the user populate incorrect/invalid data from excel sheet and which is not exist in u_aqcc table it should be ignore AQCC Name field for that corresponding row. Since it's creating a ghost record in u_aqcc table.

 

I think it required few changes in our script. Kindly help me on it.