Calculating Risk Rating
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2022 03:10 AM
Hi Everyone,
I have two fields ( 'Risk Value' and 'Risk Rating') on the form, based on the Risk Value like,
0-5->low
6-10->Medium
11-15->High
>16-very high
Risk rating will be calculated like low, Medium, High, etc.
Code:
After BR: updated checked
Condition: Risk Value changes
------------------------------------------------------------------------------------
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var result = '';
var val = current.getValue('risk_value');
gs.info('val');
if (val < 5)
result = 'LOW';
else if (val < 10)
result = 'Medium';
else if (val < 15)
result = 'High';
else if (val > 15)
result = 'Very High';
var ans = result.split('.');
gr.risk_rating = ans[0];
gr.update();
gs.addInfoMessage("Risk score:" + risk_rating);
})(current, previous);
Code is not working, Could you please help me on this.
FYI,
Thank you.
- Labels:
-
Risk Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2022 05:36 AM
Hi Try below code
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var result = '';
var val = current.getValue('risk_value');
gs.info(val);
var result = '';
if (val < 5){
result = 'LOW';
}
else if (val < 10){
result = 'Medium';
}
else if (val < 15){
result = 'High';
}
else if (val > 15){
result = 'Very High';
}
var ans = result.split('.');
current.setValue('risk_rating',ans); // rather than gr.risk_rating = ans[0] because we never declared gr object
})(current, previous);
Please check it helpful or not
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-29-2022 05:41 AM
Its working as expected now by using this code.
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var result = '';
var val = current.getValue('risk_value');
gs.info('val');
if (val < 5)
result = 'LOW';
else if (val < 10)
result = 'Medium';
else if (val < 15)
result = 'High';
else if (val > 15)
result = 'Very High';
var ans = result.split('.');
current.risk_rating = ans[0]; // changed to current from gr
current.update(); // changed to current from gr
gs.addInfoMessage("Risk score:" + risk_rating);
})(current, previous);