How to add quantity and attachment from catalog form in csm portal to related RITM, SCTask ?

Abhijit Das
Tera Contributor

How to add quantity and attachment from catalog form in csm portal to related SCTask,  after submission of the Request ?

I want to add the highlighted quantity and attachment from the catalog form in csm portal to respective RITM, specifically to related SCTask after submission of the Request.

AbhijitDas_0-1749529930328.png

 

@Ankur Bawiskar Platform Experts 

 

Looking forward to your response.

Thanks,

Abhijit

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Abhijit Das 

so you want to pick quantity and attachment and add to sc_task?

You can copy attachment when sc_task is inserted and it will copy file from RITM to SC Task

But why quantity is required?

After insert business rule on sc_task

(function executeRule(current, previous /*null when async*/ ) {

    // Add your code here
    new GlideSysAttachment().copy('sc_req_item', current.request_item, 'sc_task', current.sys_id);

})(current, previous);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@Abhijit Das 

so you want to pick quantity and attachment and add to sc_task?

You can copy attachment when sc_task is inserted and it will copy file from RITM to SC Task

But why quantity is required?

After insert business rule on sc_task

(function executeRule(current, previous /*null when async*/ ) {

    // Add your code here
    new GlideSysAttachment().copy('sc_req_item', current.request_item, 'sc_task', current.sys_id);

})(current, previous);

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Thanks @Ankur Bawiskar , the above answer is correct. I have got the scenario 2 answer as well.

(function executeRule(current, previous /*null when async*/) {

	var taskRec = new GlideRecord('sc_task');
	taskRec.addQuery("request_item.request", current.table_sys_id.toString());
	taskRec.query();
	while(taskRec.next()){
		GlideSysAttachment.copy(current.table_name.toString(), current.table_sys_id.toString(), "sc_task", taskRec.sys_id.toString());
	}

})(current, previous);

Thanks for your immediate support.

Abhijit Das
Tera Contributor

Quantity is required, since these are hardware items for the store, so there can be more than 1 quantity.
Also can you help in achieving the next scenario -  Copy attachment in SC Task, when requester update from Portal.