unable to send attachment from the record producer to target record while updating

Rohith Sureshk1
Tera Contributor

Hello,

I am working on a requirement where i use a record producer to both creating and updating a record in custom table. 

When creating a record , record producer is sending attachment correctly, But the problem is , while updating the same record , the attachment is not getting added along with old attachment in the target record that is being updated.

 

Any help on how to achieve this?

 

I am using record producer script for updating the record.

Thanks

7 REPLIES 7

Dnyaneshwaree
Mega Sage

Hello @Rohith Sureshk1 ,

Please post your script here so I can suggest needed changes.

Please accept my solution if it works for you and thumps up to mark it as helpful.
Thank you!!

Dnyaneshwaree Satpute
Tera Guru

//gliderecord script:

 

this is the code, here i am updating a record.  i want to add any new attachment added while updating record

 

if(producer.action = "update_record"){ //user can choose if they want to update/create a record

var gr_custom = new GlideRecord("custom_table");

gr_custom .addQuery("sys_id" , producer.selected_record) //selected record contains the sysid of target record we wanna update

gr_custom .query();

if(gr_custom.next()){

 gr_custom.begin_date = producer.start_date;

gr_custom .description = producer.label+producer.additional_requirement;

gr_custom.update();

current.setAbortAction(true);

}

}

else{

  gs.addInfoMessage("New Record has been created");

}

Rohith Sureshk1
Tera Contributor

@Ankur Bawiskar Any idea on this requirement? Thanks in advance

@Rohith Sureshk1 

you are aborting in update operation so try getting the sys_attachment record associated to this record producer

if you get that then you can copy to target record

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