- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2023 02:59 PM
Hi Everyone,
I have created a Record Producer where one variable type created as Attachment. When we are trying to attach documents through this, same document are getting attached 2 times.
On notes section on task record one document is showing blank and one document have correct data, However on attachment bar (top of the record) only one doc is showing and have no data.
If we are trying to attach the documents through attachment icon(out of the box), its working fine.
Please help me on this
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2023 07:08 PM
Gotchu!
Yes the attachments that are added to the attachment variable will only be displayed in notes section.
If you want to attach it to top of the record then you use below script. I have tried this a long back and it worked for me.
Create Async BR with high order and with high priority on table where record producer is created and give the correct conditions:
(function executeRule(current, previous /*null when async*/ ) {
var gr = new GlideRecord("sc_item_produced_record");
gr.addEncodedQuery("producer=ac2b37631b133010558d639bbc4bcbfb^record_table=incident^task=" + current.sys_id.toString()); // here replace with your record producer sys_id and replace with target table name where record is getting created
gr.query();
if (gr.hasNext()) {
var abc = new GlideRecord('sys_attachment');
abc.addQuery('table_name', 'ZZ_YY' + current.getTableName());
abc.addQuery('table_sys_id', current.sys_id.toString());
abc.query();
while (abc.next()) {
abc.table_name = current.getTableName();
abc.update();
}
}
})(current, previous);
Let me know if you stuck any where
Happy to help:)
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-19-2023 03:08 PM
I think may be BR running on attachment table which is leading to creating the duplicate record.
Please check if any such BR's.
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2023 02:22 PM
Hi @Murthy Ch : I have noticed that previous developer had written below script in record producer to attach one more document because When documents were getting attached through "Attachment" type variable, its passing to target record but showing in notes section only not on the top of record.
But new attachment on the record don't have any data, its showing blank, Could you please review and suggest on this?
var gr = new GlideRecord('sys_attachment');
if(gr.get(producer.attachment)){
gr.table_name='idea';
gr.table_sys_id=current.sys_id;
gr.insert();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2023 07:08 PM
Gotchu!
Yes the attachments that are added to the attachment variable will only be displayed in notes section.
If you want to attach it to top of the record then you use below script. I have tried this a long back and it worked for me.
Create Async BR with high order and with high priority on table where record producer is created and give the correct conditions:
(function executeRule(current, previous /*null when async*/ ) {
var gr = new GlideRecord("sc_item_produced_record");
gr.addEncodedQuery("producer=ac2b37631b133010558d639bbc4bcbfb^record_table=incident^task=" + current.sys_id.toString()); // here replace with your record producer sys_id and replace with target table name where record is getting created
gr.query();
if (gr.hasNext()) {
var abc = new GlideRecord('sys_attachment');
abc.addQuery('table_name', 'ZZ_YY' + current.getTableName());
abc.addQuery('table_sys_id', current.sys_id.toString());
abc.query();
while (abc.next()) {
abc.table_name = current.getTableName();
abc.update();
}
}
})(current, previous);
Let me know if you stuck any where
Happy to help:)
Murthy