Compare variable value and in a variable set variable value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2025 06:05 AM - edited 03-07-2025 06:12 AM
Hi All,
Hi All,
I am currently working on a requirement that involves the following:
- A normal variable: assistant_name_to_add
- A variable from a variable set (people_supported_and_level_of_access), which contains a variable: names_of_the_people_supported
I am trying to compare these two variables and clear the values through an onChange script if they are the same. However, I am encountering an issue where the People Support variable is returning an empty value in the alert, even though it has a value.
Below is the code I am using:
Could you please review the code and let me know what I might be missing?
Your assistance in this matter would be greatly appreciated.
Thank you in advance for your help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2025 06:25 AM
@Sirri
Is it a MultiRow Variable Set?
Could you provide screenshot of the form?
If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2025 08:14 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2025 06:43 AM
Hi @Sirri,
Please copy the sys_id of your variable set and try to access your variable set as follow:
g_form.getValue("IO:SYS_ID_OF_YOUR_VARIABLE_SET")I have just tried it:
This would return a a sting in a JSON format:
Rest, would be to JSON.parse the value you got and extract the data you need from the variable set.
If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2025 08:25 AM
@Medi C ,
If my variable set sys id is 7b2ca032db36d01074e716f35b9619b3 how can I separate please can you provide script as per my requirement.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-07-2025 09:29 AM
@Sirri, Please try the following, use debugging methods and adjust it according to your requirements.
var peopleSupported = JSON.parse(g_form.getValue("IO:7b2ca032db36d01074e716f35b9619b3"));
for(var i=0; i<peopleSupported.length; i++){
var name = peopleSupported[i].names_of_the_people_supported;
//NOW YOU CAN COMPARE VARIABLE name to other values
if (removeassistant == name) {
g_form.clearValue('assistant_name_to_add');
g_form.showFieldMsg('assistant_name_to_add', 'Assistant or Delegate Name to Add and Names of the people supported cannot be the same.', 'error');
}
}
If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.
