Creating bulk catalog task by uploading excel or csv file in RITM table using Ui action

Kishor O
Tera Sage

The requirement is to create a bulk number of tasks based on an Excel or CSV file uploaded by the user in RITM form using UI action.

 

KishorO_0-1709548286991.png

 

 

4 REPLIES 4

omkar_jadhav_
Tera Contributor

hello @Kishor O 
1. Create an Import Set :
        (Select the table where you want to store the imported task data, Define the fields that will be mapped from the uploaded file to the target table. Ensure the field names and data types in the file match the corresponding fields in the target table)
2. Create a Transform Map :
        Select the import set that you have created as the source table, Select the target table where you want to store the task data as the target table
        Map the fields from the source table
3. Create a UI Action :
                 Select the RITM form where you want to add this action, and set the "Available From" field based on your desired trigger
                onClick = ritmTask()
  Script: =

omkar_jadhav__0-1709551235321.pngomkar_jadhav__1-1709551258967.png

 

 

@omkar_jadhav_ Could you please share the code here?

*It is difficult to check it from image

 

Sure, Please find below

function ritmTask(){
var uploadedFile = current.variables.your_file_upload_field.fileName;

if (!uploadedFile) {
  gs.warning("Please upload a file before running this action.");
  return;
}

var importSet = new GlideRecord('ImportSet');
importSet.addQuery('name', 'RITM Tasks Import'); // Replace with your import set name
importSet.query();

if (!importSet.next()) {
  gs.error("Import set 'RITM Tasks Import' not found.");
  return;
}

var grImportSet = new GlideRecord('ImportSetTable');
grImportSet.initializeFromGlideRecord(importSet);
grImportSet.setValue('file', uploadedFile);
grImportSet.setValue('sys_id', importSet.getUniqueValue());
grImportSet.insert();


var transformMap = new GlideRecord('TransformMap');
transformMap.addQuery('name', 'RITM Tasks Import Map'); // Replace with your transform map name
transformMap.query();

if (!transformMap.next()) {
  gs.error("Transform map 'RITM Tasks Import Map' not found.");
  return;
}

var transformProcess = new TransformProcess();
transformProcess.setTableName(transformMap.getValue('target_table'));
transformProcess.setTransformMap(transformMap.getUniqueValue());
transformProcess.setImportSet(importSet.getUniqueValue());
transformProcess.execute();

gs.notice("Tasks successfully imported from the file.");
}

@omkar_jadhav_ I will implement this and let you know the result.
Thanks,

Kishor Otepadpu