- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2023 08:19 AM - edited 10-26-2023 09:20 AM
I have a record producer that currently has a variable set with an amount field and if a user tries to submit a request with amount < $10.00, then a client script is ran, and a prompt appears notifying the user that a request is not required to be submitted and it clears the amount field.
Within the same record producer, there is another variable set configured as a MRVS and contains a Yes/No variable 'requires_research' and if that variable is set to Yes, then the client script needs to be ignored, and the user must submit the request regardless of the amount, even if < $10.00.
So essentially, the condition would be:
If the amount is < $1.00 && 'requires_research' is No, notify the user with an on-screen info message and clear the amount field.
Else If 'requires_research' is Yes, no message appears, amount remains, and user must submit the request, regardless of the amount.
Here is my client script:
var val = 10;
var researchNeeded = '';
var multiRowVariableSet = JSON.parse(g_form.getValue('additionalinfo')); // get the MRVS name
for(var i = 0 ; i < multiRowVariableSet.length ; i ++){
if(multiRowVariableSet[i].requires_research == 'No'){ // get the variable name
researchNeeded = 'False';
}
else {
researchNeeded = 'True';
}
}
if(g_form.getIntValue('amount')<=val && researchNeeded == 'False'){ // if the amount is < $10.00 & requires_research is No
var answer = confirm('Based on the amount entered, you do not need to submit this request');
if (!answer){
g_form.clearValue('amount');
}
else{ // otherwise, if requires_research == Yes, user can submit the request and no confirmation prompt appears
g_form.clearValue('amount');
}
}
The prompts aren't working as expected in the Service Portal when submitting the request with either of these conditions.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2023 09:05 AM
Hi neil_b,
Your 'for' loop has "
i < gr.length
and I don't see where 'gr' is defined. Do you mean to use 'multiRowVaribleSet.length' there?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2023 09:05 AM
Hi neil_b,
Your 'for' loop has "
i < gr.length
and I don't see where 'gr' is defined. Do you mean to use 'multiRowVaribleSet.length' there?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2023 09:14 AM
@Bert_c1 good catch! I will try and update that and see if it works! One second.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2023 09:21 AM - edited 10-26-2023 09:35 AM
@Bert_c1 that was it! Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2023 01:06 PM
Another thing I need to mention is that onChange does not work with MRVS.
I discovered that I had to change this from OnChange to OnSubmit, and then the client script finally worked. 🙂