- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 04-30-2021 12:03 AM
On the community I found a lot of questions and blogs on how-to automatically transform attachments from an email into data in a table. These blogs either use script includes, scheduled scripts or business rules and mostly a combination of all. With the Flow Designer this is made a lot easier.
First we need to create a Data Source (Filter Navigator: System Import - Data Source). This record contains all the information about our attachment. In our example we will be creating users with a CSV file (comma delimiter). Save the record.
In the related list - transform, create a new transform map. Provide the mandatory fields (source table is the import set table just created in the data source and target table is the sys_user table). The related link Mapping Assists helps with the mapping of the fields.
Now we can start building our Flow (Process Automation - Flow Designer). Our trigger is an Inbound email with an attachment. The final flow will look something like this.
To automate the transform from the attachment on the data source. Action number 4 is created (Click on the + in the tab and create new action).
Create two action inputs:
Add a script step (green +). Create two Input Variables and use the pills from the input as values in the variables.
The script will look like this:
(function execute(inputs, outputs) {
var dataSource = new GlideRecord("sys_data_source");
dataSource.get(inputs.dataSource);
var loader = new GlideImportSetLoader();
var importSetRec = loader.getImportSetGr(dataSource);
var ranload = loader.loadImportSetTable(importSetRec, dataSource);
importSetRec.state = "loaded";
importSetRec.update();
var transformWorker = new GlideImportSetTransformerWorker(importSetRec.sys_id, inputs.transformMapSysID);
transformWorker.setBackground(true);
transformWorker.start();
})(inputs, outputs);
Save and Publish your action. (You can also test if the action works by running a test and providing the inputs with the sysid's from the create transform map and data source.
Back in the flow you can drag the pills to the action this will provide the script with the correct sysids (and makes it reusable):
After this you should add the Delete Attachment action to clean up your data source.
Save and activate and you have an automated email attachment transformer.
I am always learning new stuff, so please if you have questions, remarks or ideas on how to do this more easily. Please comment.
- 5,130 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
I am working in App Engine Studio with a Robust Transformer and therefore a scoped app. I get the following error on the custom action:
Error: GlideImportSetLoader is not allowed in scoped applications
Any suggestions?
Melissa
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
I see the same exception
Error: GlideImportSetLoader is not allowed in scoped applications
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Hi,
I recommand to use the flow on Global application, then it will work with GlideImportSetLoader.
After, you will be able to use your flow from the global application to your scoped application.
Regards,
Fayçal EL GHARBI