Some PDIs are currently unavailable, and PDI actions are paused. View the latest updates here. Read More

Automate Transform map using catalog item for end users

Sriram28
Tera Contributor

Hello All,

 

I have a similar requirement as per below video:

 

Automate Transform map using catalog item for end users 

To give insights about the video above:

 

"Create a ServiceNow Flow that automatically processes Excel files uploaded through the "Test Compliance Case" catalog item and creates Compliance cases using an existing Data Source, Import Set, and

Transform Map"

 

So, everything in place and also creating cases once attachment submitted through catalog.

 

But I have few more questions on this and issues as well.

 

Extended requirement:

 

1. I wanted to update work notes of RITM that which is submitted with attachment and processed with transform map with following details like:

 

Capture Import Results on the respective RITM:

Retrieve import/transform statistics, including:

Rows Processed

Records Inserted (Cases Created)

Records Skipped

Errors

 

2. On successful completion of transform map execution, set or close the RITM 

3. If transform execution fails, update worknotes with results and close incomplete the RITM.

 

Issues I am facing:

 

1. post import script to delete already existing attachment on data source is not getting deleted using
 

var attach= new GlideSysAttachment();

attach.deleteAll(data source);

 

2. And executions are happening many times even I submit the catalog once in portal using catalog, but case is creating only once. But many times, execution record getting created.

 

Please help me in how to go technically with above requirements and how to fix the issues that I am facing

 

Thanks in advance. 

 

 

In this video, we will learn how to automate data import into ServiceNow using the catalog item. ServiceNow is a powerful platform that helps organizations manage their digital workflows. With its powerful data management capabilities, ServiceNow can streamline data import tasks, saving you time ...
2 REPLIES 2

pavani_paluri
Kilo Sage

Hi @Sriram28 ,

 

Based on your requirement, you are already able to upload the Excel file through the Catalog Item and create Compliance Cases using the Data Source, Import Set, and Transform Map. The remaining requirements can be achieved with some additional logic in the Flow/Script.

 

1. Update RITM Work Notes with Import Results

After the Transform Map execution completes, retrieve the import statistics from the Import Set/Transform History records. ServiceNow stores information such as:

  • Rows Processed
  • Records Inserted (Cases Created)
  • Records Skipped/Ignored
  • Error Count

These values can be added to the Work Notes of the corresponding RITM.

Example Work Notes:

 

Import Process Completed
 
Rows Processed : 100
Cases Created : 95
Records Skipped: 3
Errors : 2

 

ServiceNow maintains these statistics in the Import Set Run and Transform History records, which can be queried after the transform execution completes.

 

2. Close the RITM on Successful Completion

Once the Transform Map execution is completed successfully and there are no errors:

  • Update the Work Notes with the import summary.
  • Set the RITM state to Closed Complete.

Typical flow:

 

Catalog Item Submitted
Load Data Source
Run Transform Map
Get Import Statistics
Update Work Notes
Close Complete
 

3. Close the RITM as Incomplete on Failure

If the Transform Map fails or the import process throws errors:

  • Update the Work Notes with the error details.
  • Set the RITM state to Closed Incomplete.

Example:

Transform Execution Failed
Rows Processed : 100
Errors : 15
Please review the import logs for additional details.

 

 

Issue 1: Attachment Not Getting Deleted from Data Source

The following code is not correct:

var attach = new GlideSysAttachment();
attach.deleteAll(data source);

deleteAll() expects a GlideRecord, not a variable name or string value. The correct approach is:

 

var ds = new GlideRecord('sys_data_source');
if (ds.get(dataSourceSysId)) {
var gsa = new GlideSysAttachment();
gsa.deleteAll(ds);
}
 

Alternatively, you can explicitly delete each attachment one by one, which is often more reliable. ServiceNow's GlideSysAttachment API supports retrieving attachments and deleting them individually.

 

Issue 2: Multiple Execution Records Created

If the catalog item is submitted only once but multiple execution records are created, usually one of the following is happening:

Scenario 1: Flow is Triggering on Update

Verify whether the Flow trigger is configured as Created or Updated

Instead of Created only

During catalog submission, the RITM gets updated multiple times, which can create multiple flow executions.

 

Scenario 2: Attachment Copying Causes Record Updates

If your flow:

  1. Receives the attachment on RITM
  2. Copies it to the Data Source
  3. Updates the record

those updates may retrigger the Flow and create additional execution records.

 

Scenario 3: Import is Invoked More Than Once

Check that you are not:

  • Calling the Transform Map through a Script, and
  • Also calling a Flow Designer "Transform Data" action.

This can produce multiple import executions even though the final case is created only once.

 

Scenario 4: Recursive Flow Execution

Sometimes the Flow updates the RITM itself.

Example:

 

Flow Starts
Update RITM
RITM Update triggers Flow again
New Execution Created

 

To avoid this:

  • Trigger only on Create, or
  • Use a flag field such as u_import_processed = true, and
  • Add conditions so the flow runs only once.

 

Recommended Solution

 

RITM Submitted
Copy Attachment to Data Source
Delete Old Data Source Attachments
Load Import Set
Run Transform Map
Capture Import Statistics
Update RITM Work Notes
Success? - Yes  -> Closed Complete
No -> Complete Incomplete
`

This approach will meet all three requirements and also help eliminate duplicate execution records.

 

Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Pavani P

hi @pavani_paluri ,

 

Thanks for all explaining in detail with patience.

 

As per the flow provided :

 

RITM Submitted
Copy Attachment to Data Source
Delete Old Data Source Attachments
Load Import Set
Run Transform Map
Capture Import Statistics
Update RITM Work Notes
Success? - Yes  -> Closed Complete
No -> Complete Incomplete
 
Could you please give provide some technically to do everything in flow designer for entire process.
 
Thanks in advance