- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2023 04:02 AM
HI,
i have created a catalog item and user MRVS in that, there are 2 fields in multi row
request_type = action and deletion
association = Non government and government
Now i want a condition to check if request type is action or deletion && association is No government then its Yes otherwise No
I tried to write MRVS script but not working
Multi row variable set internal name: declaration_list
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2023 06:47 AM
you didn't answer my above question
are you saying if any 1 row satisfies that condition then you want to return yes or all rows should satisfy that condition?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2023 07:10 AM
No it should check all rows, if out of 5 mrvs records 3 mrvs rows dont met condition it should say no, If all 5 are meeting conditions then should go to Yes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2023 07:33 AM
ok so if all rows meet condition then only Yes
update as this
answer = ifScript();
function ifScript() {
var multiRowVarSet = current.variables.declaration; // variable set internal name
var rowCount = multiRowVarSet.getRowCount();
var isValid = false;
for (var i = 0; i < rowCount; i++) {
var row = multiRowVarSet.getRow(i);
var declarationType = row.declaration_type;
var associate = row.associate;
if (declarationType == 'Gift' || (declarationType == 'Hospitality' && associate == 'Non Government ')) {
isValid = true;
}
else{
isValid = false;
}
}
if(isValid)
return 'yes';
else
return 'no';
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2023 12:47 AM
I put his code now when i am raising the request it is always taking as Yes, if the conditions are not met even then also, i put associate as Government insted of No government then also it is taking as Yes
answer = ifScript();
function ifScript() {
var multiRowVarSet = current.variables.declaration; // variable set internal name
var rowCount = multiRowVarSet.getRowCount();
var isValid = false;
for (var i = 0; i < rowCount; i++) {
var row = multiRowVarSet.getRow(i);
var declarationType = row.declaration_type;
var associate = row.associate;
if (declarationType == 'Gift' || declarationType == 'Hospitality' && associate == 'Non Government Official') {
isValid = true;
} else {
isValid = false;
}
}
if (isValid)
return 'yes';
else
return 'no';
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2023 12:52 AM
did you check by adding gs.info() in the for loop
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader