- 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
‎01-10-2019 06:44 AM
The link is dead I tried getting to it but no luck. Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2019 05:24 AM
Modify code as below,
var rc = cart.placeOrder();
gs.addInfoMessage("Purchase request has been submitted. Request number is " + rc.number);
var sys_id1 = current.getUniqueValue();
var sys_id ;
current.addQuery('request',rc.sys_id);
current.query();
if(current.next()){
sys_id = current.sys_id;
}
GlideSysAttachment.copy('sc_task',sys_id1,'sc_task',sys_id);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2019 06:43 AM
Hello,
Unfortunately this did not work.
Thanks,
Chad

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2019 06:54 AM
Can you try the below script
var gr = new GlideRecord("sc_task");
gr.addQuery("request", rc.sys_id);
gr.query();
var id
if (gr.next()) {
id = gr.sys_id;
}
GlideSysAttachment.copy('sc_task',current.getUniqueValue(),'sc_task',id);
- 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);
}