- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2024 10:35 AM
Hi Team,
Create a 2 fields in the Custom table:
Risk Level: choice[Critical, High, Medium and Low]
Barr Level: String Only set Value[Critical, High, Medium and Low]
Requirement: compare the Barr Level is Higher then the Risk Level.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2024 08:53 PM
you can use a Business Rule or a Script Include to compare the values of the "Risk Level" and "Barr Level" fields whenever a record is inserted or updated in the custom table.
(function executeRule(current, previous /*null when async*/) {
// Get the values of Risk Level and Barr Level
var riskLevel = current.getValue('risk_level');
var barrLevel = current.getValue('barr_level');
// Map the text values to their corresponding numerical values
var riskLevelValue = getNumericValue(riskLevel);
var barrLevelValue = getNumericValue(barrLevel);
// Compare the values
if (barrLevelValue < riskLevelValue) {
// Barr Level is lower than Risk Level
gs.addErrorMessage("Barr Level cannot be lower than Risk Level.");
current.setAbortAction(true); // Abort the transaction
}
// Function to map text values to numerical values
function getNumericValue(level) {
switch (level) {
case 'Critical':
return 4;
case 'High':
return 3;
case 'Medium':
return 2;
case 'Low':
return 1;
default:
return 0; // Default value or error handling
}
}
})(current, previous);
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2024 11:18 AM
Hi @Pankaj15 ,
Could u please elaborate ur requirement , as it is not very clear when u say compare barr level with risk level
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2024 11:41 AM
Yes , compare Bar Level with risk Level
Bar Level: Critical ,High, Medium and Low
Risk Level: Critical ,High, Medium and Low
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2024 01:58 PM
So is it something like if risk level is high then Barr level should be set to High?
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2024 01:10 PM
Hi @Pankaj15
Do you want Bar level to be always higher than Risk level? If yes, you can write a Onchange client script on Bar level field, here you can check the value of Risk level and then if Bar level is lower than Risk level you can display an error message and clear the value from the field.
Let me know if I was able to understand your requirement clearly or if you need any help with the script.
Please mark this response helpful or correct, if it helped you.
Regards,
Rishi.