
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2019 12:45 PM
I'm hoping that I'm doing something stupid here... I'm trying to take values from a multi-row variable set on a record producer and create them as records in a table related to the one for which the primary record from the record producer is created. E.g. Record producer creates main record. Each row in the multi-row variable set is represented as a row in the supporting table, referencing the main record. This is all within a scoped app.
I've got it working with no issue from a background script once the record has been submitted. However, the same code (modified for context) doesn't work in a business rule running after insert on the table represented below as "x_payment."
/* used in background script only */
var current = new GlideRecord('x_payment');
current.get('__sys_id__');
/* */
var grRow = new GlideRecord('x_funding_sources');
var mrvs;
mrvs = current.variables.funding_sources;
var mrvsArray = JSON.parse(mrvs);
for (i = 0; i < mrvsArray.length; i++) {
grRow.initialize();
grRow.payment = current.sys_id;
grRow.cost_center = mrvsArray[i].cost_center;
/* etc. */
grRow.insert();
}
Solved! Go to Solution.
- Labels:
-
Scoped App Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2019 10:18 AM
Hey Robert-
I couldn't get this working with an After business rule either so I ran the business rule Async instead and that seemed to work well for me. Hope this helps!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-25-2019 10:18 AM
Hey Robert-
I couldn't get this working with an After business rule either so I ran the business rule Async instead and that seemed to work well for me. Hope this helps!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-28-2019 06:55 AM
Interesting--yeah, that seems to do it. Thanks, Matt!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2020 05:40 PM
Having similar trouble, would you mind sharing your BR script? Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-02-2020 04:13 AM
This is very efficient than Glide 'sc_multi_row_question_answer' table .
Here is my working script.
(function executeRule(current, previous /*null when async*/ ) {
var mrvs = current.variables.vendor_information;
var totalRows = mrvs.getRowCount();
var total = 0;
for (var i = 0; i < totalRows; i++) {
total = total + mrvs.getRow(i).getCell('vendor_price').getCellDisplayValue() * mrvs.getRow(i).getCell('quantity').getCellDisplayValue();
}
var req = new GlideRecord('sc_request');
req.get(current.request);
req.price = total.toFixed(2);
current.price = total;
})(current, previous);