Email notification with errors from import set in Flow.

Pablo H
Tera Contributor

Hello everyone,

 

little bit of background, I have create a flow for catalog item, user will attach an excel file and via flow, data is automatically imported to the target table. 

 

As a next step, I would like to add email action to the flow if errors occure during the data import, the email should contain all of the error messages. Can you advise what is the best approach to do this?

 

Thank you

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Pablo H 

better to use direct notification on table sys_import_set_run (Transform History).

You can call this notification from your flow using Send Notification action

something like this to show the status of inserts, updates, ignored, skipped etc

Email script:

(function runMailScript(current, template, email, email_action, event) {

	template.print("Total:"+current.total+"<br/>");
	template.print("Inserts:"+current.inserts+"<br/>");
	template.print("Updates:"+current.updates+"<br/>");
	template.print("Ignored:"+current.ignored+"<br/>");
	template.print("Skipped:"+current.skipped+"<br/>");
	template.print("Errors:"+current.errors+"<br/>");
	//}

})(current, template, email, email_action, event);

Import Set Email.gif

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

8 REPLIES 8

The SN Nerd
Giga Sage
Giga Sage
  1. Get a copy of the file. The excel file provided for this flow will always need to be in the same format
  2. Create a data source, transform map and import set based on this template
  3. Test with some data to make sure it works
  4. Create scheduled import for that data source
  5. Add attachment variable to your catalog item
  6. Create flow
  7. Adapt solution on this blog post to execute scheduled import using attachment from variable instead of attachment from email

    https://www.servicenow.com/community/now-platform-articles/import-excel-file-from-inbound-email-via-...

     

 


ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

Thank you for response. I want to extract error messages from import data, if any occured and send those via email via flow.

Ankur Bawiskar
Tera Patron
Tera Patron

@Pablo H 

better to use direct notification on table sys_import_set_run (Transform History).

You can call this notification from your flow using Send Notification action

something like this to show the status of inserts, updates, ignored, skipped etc

Email script:

(function runMailScript(current, template, email, email_action, event) {

	template.print("Total:"+current.total+"<br/>");
	template.print("Inserts:"+current.inserts+"<br/>");
	template.print("Updates:"+current.updates+"<br/>");
	template.print("Ignored:"+current.ignored+"<br/>");
	template.print("Skipped:"+current.skipped+"<br/>");
	template.print("Errors:"+current.errors+"<br/>");
	//}

})(current, template, email, email_action, event);

Import Set Email.gif

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar One more question, how to call the notification from the flow via Send notification action and and the same time keep the conditions for the notification? I can only see these two notification.

PabloH_0-1665062855769.png