- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2024 05:11 AM
Hi Team, Good morning!
How to hide the state option on the change form?
for example: when approval is approved then show only state options like canceled, closed completed, and closed incompleted.
Thank you!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2024 06:11 AM
Hello @Alex78 ,
Yes you can achieve this by using onLoad client script or if you want to filter the choices on change then you can use onChange client script as well and show the options only which you want to show based on field value.
You can refer the below sample script as well for better understanding.
function onLoad() {
// Assuming 'approval' is the field representing approval status
var approvalStatus = g_form.getValue('approval');
// Array of state options to hide for certain approval status
var statesToHide = ['1', '2', '3']; // Add the state values you want to hide
// Remove options based on approval status
if (approvalStatus === 'approved') {
for (var i = 0; i < statesToHide.length; i++) {
g_form.removeOption('state', statesToHide[i]);
}
}
}
Or else you can refer the below article as well for in detailed information about how to hide or show the choices
Let me know your views on this and Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks,
Aniket
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2024 05:27 AM
Hi @Alex78,
availability/visibility of states and their transitions are usually defined within the change model. You could define that in a model state transition definition. If you don't use that approach, you could use a client script and work with g_form.addOption() and g_form.removeOption().
Best regards,
Rene
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2024 05:50 AM - edited 01-01-2024 05:59 AM
Hi @Alex78 ,
U need to use an onChange client script & the variable u need to select is approval variable.
Once approval variable is approved u need to remove all the other options
Something like
if(newValue == "approved"){
g_form.removeOption("field_name","value");
}
Thanks,
Danish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2024 06:11 AM
Hello @Alex78 ,
Yes you can achieve this by using onLoad client script or if you want to filter the choices on change then you can use onChange client script as well and show the options only which you want to show based on field value.
You can refer the below sample script as well for better understanding.
function onLoad() {
// Assuming 'approval' is the field representing approval status
var approvalStatus = g_form.getValue('approval');
// Array of state options to hide for certain approval status
var statesToHide = ['1', '2', '3']; // Add the state values you want to hide
// Remove options based on approval status
if (approvalStatus === 'approved') {
for (var i = 0; i < statesToHide.length; i++) {
g_form.removeOption('state', statesToHide[i]);
}
}
}
Or else you can refer the below article as well for in detailed information about how to hide or show the choices
Let me know your views on this and Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks,
Aniket
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-01-2024 06:13 AM
Hello @Alex78 ,
You can write a simple onload client script as below. Please remeber to change appropriate field name and options to remove as per you business case.
function onLoad() {
var approval = g_form.getValue('approval');
if (approval == 'approved') {
g_form.removeOption('state', '1');
}
}
Kindly mark the answer ✔️Correct or Helpful ✔️If it addresses your concern.
Regards,
Siddhesh