Copy all attachments from Idea to Demand

RakshithaM
Tera Contributor

Hi,

 

I want to copy all the attachments which are present on Idea to Demand. 

I have used After business rule with Insert for below code.

 

But the below code isn't working as per requirement. Can someone guide me where I need to correct.

Have attached screenshot for reference.

Thankyou.

 

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

    var demandTable = "dmn_demand";
    if (GlidePluginManager.isActive('com.snc.project_management_v3')) {
        demandTable = SNC.PPMConfig.getDemandTable(current.getTableName());
    }
    var demand = new GlideRecord(demandTable);
    var dmnId = demand.insert();
    demand.get(dmnId);
    current.demand = dmnId;
    current.stage = 'demand';
    GlideSysAttachment.copy('idea',current.sys_id, 'dmn_demand', demand.sys_id);
   
    var message = gs.getMessage("Demand {0} has been created");
})(current, previous);

 Screenshot 2025-05-15 203333.png

7 REPLIES 7

not yet.

Ankur Bawiskar
Tera Patron
Tera Patron

@RakshithaM 

how is idea table related to demand?

you have to define the field and then copy it to the record

check this link

copy attachment from idea to demand 

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

SumanthDosapati
Mega Sage
Mega Sage

@RakshithaM 

This link might help you.

 

Regards,
Sumanth