Set variable ReadOnly when Multi Row Variable Set not empty
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2024 11:09 AM
Hi all,
I need some help or guidance on how to set a variable Read-Only when the Multi Row Variable Sets (MRVS) not empty i.e. once it populated at least one item.
Basically, once I added Report Name & Email the field outside of MRVS should be set to Read-Only
I've tried onLoad client script but it doesn't work quite right
function onLoad() {
var mrvs = JSON.parse(g_form.getValue('report_name_and_email'));
if(mrvs.length > 0) {
g_form.setReadOnly('add_or_remove', true);
}
}
Is there something else that I missed?
Thank you in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2024 07:29 AM
Thank you for your help but it doesn't seem to work on my my PDI is there something I missed?
1. Multiline text
2. Custom variable
3. Widget
4. Client script
I'm pretty sure I did everything
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2024 07:49 AM
First of all, are you getting mrvs value in your hidden variable?
Try below in client script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
// Do nothing if the form is loading
return;
}
if (newValue === ' ' ) {
g_form.setReadOnly('report_email', false);
} else {
g_form.setReadOnly('report_email', true);
}
}
If my response helped you, please click on "Accept as solution" and mark it as helpful.
- Saloni
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2024 07:57 AM
How can I check if I'm getting mrvs value? Like a log somewhere?
Here is the updated client script per your suggestion
Before adding anything
After select Add selection then add item into mrvs
The "Report and email" still not set to Read Only
Same thing on Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2024 08:04 AM
MRVS value should be populated in your hidden variable. For testing, make sure hidden variable is visible on the form
If my response helped you, please click on "Accept as solution" and mark it as helpful.
- Saloni
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2024 08:09 AM
It does not populate in my hidden variables