GlideSysAttachment.copy() Duplicating the record generated from Record Producer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2022 04:16 PM
Hello Guys,
Something really strange going on here.
I have a record producer generating records in 'CRIACAO JOBS'[x_farsa_criacao_jobs] table and it has a MRVS being parsed and generating records on the table [x_farsa_criacao_materials] as 'childs' to the generated 'CRIACAO JOBS'.
I needed to copy all the attachments sent thru the record producer and therefore attached to this parent 'CRIACAO JOBS' to all its children on [x_farsa_criacao_materials].
To do that I have a simple business rule running AFTER INSERT on the [x_farsa_criacao_materials] table with 1 line of code:
GlideSysAttachment.copy('x_farsa_criacao_jobs', current.job , 'x_farsa_criacao_materials', current.sys_id);
And it looks like this simple BR is the reason why the 'CRIACAO JOBS' are being generated twice (Duplicated) and causing me some trouble...
Anyone experienced the same? Does anyone know enough about this GlideSysAttachment API to recognize this weird behavior?
Thanks in advance....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-05-2022 05:57 PM
Hi, this seems a little unusual and I would not expect GlideSysAttachment() to create a new record on a table that was not sys_attachment. Are you able to reproduce this in an OOB PDI? and can you provide exact steps to reproduce?
Looking at the details you have provided, assuming current.job is a relationship to the parent record?
I would think that the 'source' sys_id is probably being set as the object 'job' and not a string of the sys_id for the 'job' record and you could try something like
current.getValue('job');
current.job.toString();
But that would only explain why the attachment was not copied, and does not explain how a new record is created.