- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â02-21-2022 10:25 PM
I want to upload data in contract table and the records contain attachment also. Can any body help how to upload the attachment data.I am getting the data through excel sheet.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â03-03-2022 01:39 AM
Then check this blog where I have recently shared the approach
is it possible to send attachment through transform map?
Tell customer to send all these details in the excel file
1) the base64encoded data of the attachment
2) file name
3) content type
once you are sure these all data is present in excel you can use onAfter transform script so that it adds attachment to that record which got created/updated
Like this
OnAfter script would be like this
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
var fileName = source.u_file_name;
var fileContentType = source.u_content_type; // such as image/jpeg or application/pdf
var fileData = source.u_base64_data;
var ecc = new GlideRecord('ecc_queue');
ecc.initialize();
ecc.agent = "AttachmentCreator";
ecc.topic = "AttachmentCreator";
ecc.name = fileName + ":" + fileContentType;
ecc.source = target.sys_class_name + ":" + target.sys_id;
ecc.payload = fileData;
ecc.insert();
})(source, map, log, target);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards
Ankur
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â07-24-2022 06:41 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â07-25-2022 10:44 PM
Direct mapping won't work.
You will have to use onBefore transform script.
You should have all the other details as well like filename, content type
Regards
Ankur
Ankur
⨠Certified Technical Architect || ⨠9x ServiceNow MVP || ⨠ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â11-30-2022 10:04 AM
Hi Ankur, how are you? I was having the same problem and decided to use your script but for some reason the attachment (image, excel, etc...) is created in servicenow but when I download it the attachment is corrupted. Do you wonder what it could be? Here are the inputs that I used in excel
And here is the attachment in servicenow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â06-20-2024 03:30 AM
Hi Ankur,
Thanks for the above.
For update scenario - where I have a set of numbers / sys ids already in the excel as a column.
In the script of transform map, I check if that number/sys id already exists then I update a particular field., which is happening properly but the attachment is sitting on a new insertion (that onafter script as suggested by you) instead of updating on the existing record that I checked in the transform script.
What am i missing here, need your help. Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
â08-20-2024 11:52 PM
Hi @Ankur Bawiskar ,
When I'm trying to do this activity. I'm getting the below error when I try to preview the attached attachment.
Can you help me to overcome this?
Thanks,
Hari