- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2021 07:55 AM
Have a scoped app with Record Producers that have a number of variables using the new Attachment variable that comes with Paris. My issue is that when the Record Producer is submitted, I need all the attachments from it copied over to the base table in the app. I found this on the Community (sorry, can't find the article again to show who wrote it), but it's an Async Business Rule that will copy over the attachments:
(function executeRule(current, previous /*null when async*/ ) {
var tableName = current.getTableName();
var sysID = current.sys_id;
var pcsAttachment = new GlideRecord("sys_attachment");
pcsAttachment.addQuery("table_name", "ZZ_YY" + tableName);
pcsAttachment.addQuery("table_sys_id", sysID);
pcsAttachment.query();
gs.info('Count: {0}', pcsAttachment.getRowCount());
while (pcsAttachment.next()) {
pcsAttachment.table_name = tableName;
pcsAttachment.update();
new global.VariableUtil().copy(pcsAttachment.sys_id, tableName, sysID);
}
})(current, previous);
In the App log, it says on one example that there are 6 records found, but only 1 of the attachments is copied.
Solved! Go to Solution.
- 2,424 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2021 08:08 AM
I've noticed when working with async BRs like this that the script doesn't run with expected results unless the BR was created in the Global Application - even if it's running on a Table that's in a scoped app.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2021 06:31 AM
Same unexpected results that I got when running the Business Rule in the scoped app. It would only copy the first attachment. This just makes it a bit clumsy when I go to move my scoped app from one instance to another. I have to make sure these Global Business Rules that I need are also brought over.
Thx for your responses Brad.