after tranformap trigger workflow issue

keshav77
Tera Contributor

Hi All,

 

I am triggring one workflow through after transformmap to create record  in api table. but is it is not working what will be the possible issue.

 

here is the below runscript of transformap --

 

// Validate key fields
if (!current.solution_center || !current.api_name) {
gs.error('Missing crucial fields for record ' + current.sys_id);
workflow.scratchpad.stop = true;
return;
}

var apiGR = new GlideRecord('cmdb_ci_api');
apiGR.addQuery('solution_center', current.solution_center);
apiGR.addQuery('api_name', current.api_name);
apiGR.query();

if (apiGR.next()) {
// Update existing record
apiGR.u_version = current.api_version;
apiGR.update();
gs.info('Updated API: ' + apiGR.sys_id);
} else {
// Create new record
apiGR.initialize();
apiGR.solution_center = current.solution_center;
apiGR.api_name = current.api_name;
apiGR.api_version = current.api_version;
apiGR.insert();
gs.info('Created new API: ' + apiGR.sys_id);
}

// No function wrapper needed—script ends here

2 REPLIES 2

Mark Manders
Mega Patron

What exactly are you doing? You say you run a workflow to create records, but this transform script is already creating records. 


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

@Mark Manders  importset creating record in end point discovered table and this transform script  record API table