create a record from attachment

vano81
Kilo Explorer

Hi All,

I am trying to resolve this task. As an user I generate email with for instance 5 attachments. ServiceNow. ServiceNow Inbound action generates record with 5 attachments in ServiceNow. In my staging table based on record with 5 attachments, 1 revision/record is created for each attachment. After createion of 5 records/revisions the staging table record is deleted.

My idea is to   copy or get these attachments to dms_document table from my staging table or directly and then force revision task. I was thinking about business rule that can be used in Inbound email action. I have found also getConent(GlideRecord sysAttachment) that can trigger this action in Inboud email action.

Looking for any ideas.

Many thanks

2 REPLIES 2

harshinielath
Tera Expert

Hi.I dint get you requirement clearly but once I had to include an attachment and did like this: script to copy attachment from one table to other.So maybe it can help you.



var sourceSysID = '1db6b56e6fa58f4882d1cf164b3ee4bf';     //sys_id of kb_article


var targetSysID = current.sys_id;


var copyAtt = new GlideSysAttachment();


copyAtt.copy('kb_knowledge', sourceSysID, 'sc_req_item', targetSysID);           //copying the attachment from kb_knowledge table to sc_req_item.



Let me know if it helps.


mohamadcharafed
ServiceNow Employee
ServiceNow Employee

Hi Marek,



Harshini has given you the code to copy attachments.


Just a note when you decide to copy incoming attachments. If you do not make a way to automatically delete these attachments in the future your instance Database will grow huge in size and you will have trouble later on for cloning etc. Especially if this feature is heavily used and has a lot of incoming attachments.



Regards,


Mohamad