- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2023 05:56 AM
Hi Experts,
I was trying to attach the files of incident record to record producer on click of UI button.
I've tried 'GlideAttachment.copy()' which helps only from record to record, but not record to form.
Can you please advise, how to make this work.
Thanks in advance..!!
Regards,
Naveen.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2023 07:43 AM
do this
1) create a string variable on record producer and give it higher order
2) pass the incident record sysId from URL parameter when you redirect user to record producer
3) use onLoad catalog client script and get that URL parameter value and set it in variable and hide it
4) then use Record producer script to copy attachment
GlideSysAttachment.copy('incident', producer.variableName, 'target_table', current.sys_id);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2023 06:08 AM
Hello @naveen80
you can send values from UI action through URL by adding parameters.
in the onload client script of record producer fetch values from url and populate in the record producer fields.
regarding attachment is somewhat difficult but you can try this:
1) send sys_id of the incident record in the url as parameter
2) in onload get the sys_id value
3) call GlideAjax function and send sys id of incident and sys id of the record producer
gel('sysparm_item_guid').value
4) use copy attachment functionality and copy attachment from incident record to record producer
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Plz mark my solution as Accept, If you find it helpful.
Regards,
Samaksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2023 06:24 AM
Hi Samaksh,
Thank you for the response..!!
I've tried the same approach, but 'gel('sysparm_item_guid').value' cannot be used in service portal.
I've also found the KB article - https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0723775
I've tried the resolution of the KB article as well, but no luck.
Expectation - I was looking to fetch the record sys_id before the record gets created from the record producer. bcoz, when I add the attachment manually I can see that attachment record is generated in to the target table.
Let me know if there is any other approach i can work up on.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2023 06:32 AM
Hello @naveen80
var item_guid = angular.element("#sc_cat_item").scope().data._attachmentGUID;
use above code as your reference to solve the query.
Plz mark my solution as Accept, If you find it helpful.
Regards,
Samaksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-05-2023 06:54 AM
Hi Samaksh,
I was getting this error - 'There is a JavaScript error in your browser console'.
can you help me with this error.
Thanks,
Naveen.