- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2024 06:01 AM
Hi Team,
I am trying to run one flow designer(with Service Catalog trigger) with business rule.
Business Rule Details: table: sc_req_item, type: before, Insert: true
Below is the script which I tried, and it is working for a single record, but I want to run flow designer for every current records which are getting inserted.
When I am passing current.sys_id in get function, it is giving me 'Incorrect GlideRecord input' error.
(function executeRule(current, previous /*null when async*/ ) {
try {
var glideRecordInput = new GlideRecord('sc_req_item');
glideRecordInput.get('some sys id');
var flowInputs = {};
flowInputs['request_item'] = glideRecordInput;
flowInputs['table_name'] = glideRecordInput.getTableName();
var result = sn_fd.Flow.startAsync('global.employee_termination_vendor_email_flow', flowInputs); //
var contextId = result.contextId; //The Sys ID of a flow execution (contextId)
} catch (ex) {
var message = ex.getMessage();
gs.log('Flow Error: ' + message);
}
})(current, previous);
Let me know how can I fix this.
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2024 08:43 AM
I have changed the type to after and passed the current record sys id to resolve this issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2024 08:43 AM
I have changed the type to after and passed the current record sys id to resolve this issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2024 08:48 AM
Change the BR type to after and use below code.
(function executeRule(current, previous /*null when async*/ ) {
try {
var glideRecordInput = new GlideRecord('sc_req_item');
glideRecordInput.get(current.sys_id);
var flowInputs = {};
flowInputs['request_item'] = glideRecordInput;
flowInputs['table_name'] = glideRecordInput.getTableName();
var result = sn_fd.Flow.startAsync('global.employee_termination_vendor_email_flow', flowInputs); //
var contextId = result.contextId; //The Sys ID of a flow execution (contextId)
} catch (ex) {
var message = ex.getMessage();
gs.log('Flow Error: ' + message);
}
})(current, previous);