- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2019 08:50 AM
Hello,
We have a business requirement to copy attachments from one sc_task to another sc_task. We currently have a catalog item that creates a sc_task for a request for quote then once the sc_task is closed complete the UI Action Purchase is available which then creates another request copying the variables from the first request. I tried to add the copy attachment code below in yellow. Any assistance would be appreciated
UI Action
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem('de44ce8013d41bc0fa7c73076144b09d'); //GTO Procurement - Quote/Purchase/Return Request
//iterate through all properties of current.request_item.variables set them as the values for the new request
for (var property in current.variables){
if (property == 'request_type')
cart.setVariable(item, property, "Purchase");
else
cart.setVariable(item, property, current.variables[property]);
}
var rc = cart.placeOrder();
gs.addInfoMessage("Purchase request has been submitted. Request number is " + rc.number);
GlideSysAttachment.copy('sc_task',current.getUniqueValue(),'sc_task',rc.sys_id);
rc.update();
action.setRedirectURL(current);
Solved! Go to Solution.
- Labels:
-
Service Catalog
-
Workflow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2019 06:49 AM
I was able to go it to work.
var newSerReqTask = new GlideRecord('sc_task');
var taskQueryString = "request=" + rc.sys_id;
newSerReqTask.addEncodedQuery(taskQueryString);
newSerReqTask.query();
//While there is a record found from the above query, add all attachments from the Quote Catalog Task to the new Purchase Catalog Task
while (newSerReqTask.next()){
var gsAttach = new GlideSysAttachment().copy('sc_task', current.sys_id, 'sc_task', newSerReqTask.sys_id);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2019 05:11 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2023 10:23 AM - edited 10-31-2023 02:11 AM
Hi @Chad Wilhelm1 ,
Should this be written in business rule or in an UI action?
Hi @Ankur Bawiskar, could you help us on this?
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-31-2023 02:22 AM
can you post a new question and share all the details there and tag me there as this is an older thread?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader