Bulk Upload of records using Inbound Action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2023 10:04 AM
I have created an Inbound email action where Data source is the target table. In this case, I am checking the body of the email as first step. If body of the email i.e., vendor (in script) exits on control table then the attachment attached in the email should work on the data source table mentioned in the script.
But somehow my script is not working on data source table (the attachment is not getting updated). Can anyone help me.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2023 10:27 AM
@Manaswini What exactly are you trying to update on sys_data_source table using the following code?
var gr1 = new GlideRecord('sys_data_source');
gr1.addEncodedQuery("name=VSC Checklist");
gr1.query();
while (gr1.next()) {
gr1.update();
}
Also, do you get vendor name using the following lines from the email body?
var vendor = email.body.vendor_organization_name;
Put gs.info(vendor); in your inbound script below the line mentioned above and see if the logs print the vendor name.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2023 10:48 AM
Hi @Sandeep Rajput ,
Firstly, Thanks for your response.
What exactly are you trying to update on sys_data_source table using the following code? - This is for updating the attachment on the data source (this should be the attachment attached on the inbound email)
do you get vendor name using the following lines from the email body? - Yes, its defined in email body

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2023 11:01 AM - edited ‎10-07-2023 11:03 AM
GlideSysAttachment - copy(String sourceTable, String sourceID, String targetTable, String targetID)
Copies attachments from the source record to the target record.
Source:
Hence you do not need any additional update action to update the attachment status on sys_data_source table.
Could you please update your code as follows and let me know if the updated code works for you.
(function runAction(/*GlideRecord*/ current, /*GlideRecord*/ event, /*EmailWrapper*/ email, /*ScopedEmailLogger*/ logger, /*EmailClassifier*/ classifier) {
// Check if the body of the email exists in the profile field of the control table
var vendor = email.body.vendor_organization_name;
var controlTable = new GlideRecord('sn_compliance_control'); // Replace with the actual table name
controlTable.addQuery("profile", vendor);
controlTable.query();
if (controlTable.next()) {
// The email body exists in the control table, execute the code below
// Set the Data Source to be used
var dataSourceID = "d767ff601bbd71104444415de54bcbdc";
// Query the attachments for this data source and delete them
var gr = new GlideRecord('sys_attachment');
gr.addQuery('table_name', 'sys_data_source');
gr.addQuery('table_sys_id', dataSourceID);
gr.query();
while (gr.next()) {
gs.info("success in running 16th line of code");
gr.deleteRecord();
}
//Copy attachment from the Email to the Data Source
GlideSysAttachment.copy('sys_email', current.sys_id, 'sys_data_source', dataSourceID);
gs.info(" success in running 22nd line of code");
}
})(current, event, email, logger, classifier);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2023 11:11 AM - edited ‎10-07-2023 11:17 AM
No Sandeep, getting "Vendor Checklist : did not create or update sys_data_source using current" in email logs.
The body of the email sharing for this inbound action is below: