Show/Hide choices of a multiple choice field based on two fields of Company chosen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024 06:13 AM
There are two fields under each Company (X and Y).
There are 2 choices under a multiple choice type field Relationship.
IF x is true , then first choice autopopulates under one field
IF y is true , then second choice autopopulates .
What to do in client scriopt?
Already created a script include and a client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024 06:21 AM
Do you have screenshot of the form?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024 06:31 AM
The two fileds inside Company are vendor and customer , if that company chosen has vendor checked then this choice of vendor should show up and likely the next.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024 06:37 AM - edited 02-15-2024 06:40 AM
Here is aa sample script:
Put this in a onchange client script, it should run on the field when you update the company relationship field
if(g_form.getValue('<company Relationship Variable Name>') == '<Company Choice Value>')
{
g_form.setDisplay('<Company variable name that should be visible>', true); // show company field
g_form.setDisplay('< Vendor variable name that should be visible>', false); // hide vendor field
}
else if(g_form.getValue('<company Relationship Variable Name>') == '<VendorChoice Value>')
{
g_form.setDisplay('<Vendor variable name that should be visible>', true); //show vendor field
g_form.setDisplay('<Company variable name that should be visible>', false); //hide company field
}
PS. make sure that UI type field on the client script is set to 'All' so that it runs on portal and native ui both.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024 06:43 AM
Hi @Mouktik_B
Use g_form.removeOption('variable_name','value','label'); to remove options
Use g_form.addOption('variable_name','value','label'); to add options
Use g_form.setValue ('variable_name','value'); to set the variable value
Please mark this response as correct or helpful if it assisted you with your question.