Dynamically Hiding Choice Values in Record Producer Based on User country
						
					
					
				
			
		
	
			
	
	
	
	
	
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2025 08:39 AM
Hi Everyone,
I'm currently working on a record producer and need some assistance with dynamically controlling the visibility of choice values for a specific variable.
Here's the scenario:
I have a variable named "Select Currency" with the following choices:
1.India INR
2.United States Dollar (USD) $
3.Euro (EUR) €
4.British Pound Sterling (GBP) £
5.Japanese Yen (JPY) ¥
6.Australian Dollar (AUD) $
The requirement is to filter these choices based on the logged-in user's country.
For example:
If the user's country is India, only "India INR" should be visible in the "Select Currency" dropdown.
If the user's country is the United States, only "United States Dollar (USD) $" should be visible.
Has anyone implemented something similar before? I'm looking for guidance on the best approach to achieve this. Should I be looking at client scripts, UI policies, or perhaps something else? Any code snippets or pointers would be greatly appreciated!
Thanks in advance for your help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2025 08:33 PM
Hello @sravanku888,
- 
Accessing User Information:You'll need to access the user's country information. This might be stored in the user's profile or a related table. The script will need to be able to retrieve this information.
- 
Example:If the user's country is stored in theuser_countryfield, you can access it usingg_user.get(user_country).
- 
onChangeFunction:Create a client script that triggers when the user changes the choice field (or when the form loads, if you want to hide values initially).
- 
Conditional Logic:Within the script, use conditional statements (e.g.,if,else if,else) to determine which choice values to hide based on the user's country.
- 
g_form.removeOption():Use theg_form.removeOption()method to remove specific choice values from the dropdown.- Example: g_form.removeOption("my_choice_field", "value_to_hide");.
 
- Example: 
- 
Example:If the user is in the US, hide certain options, and if they are in another country, hide a different set of options.
- 
Visibility Control:You can use UI policies to dynamically show or hide other fields or sections in the record producer, based on the values selected in the choice field.
- 
Condition:The UI policy's condition will be based on the value selected in the choice field (or another field related to the choice field).
- 
Action:The UI policy will either set the visibility of related fields or sections totrue(visible) orfalse(hidden).
- Connect Fields: Ensure that the choice field and any fields or sections affected by the UI policy are properly linked in the record producer. 
issue_type with values like "Problem," "Incident," and "Change." You want to hide "Change" for users in certain countries. - Access Country: Retrieve the user's country (e.g., using g_user.get(country)).
- Client Script:
    function onChange(control, oldValue, newValue, isLoading) {
        if (isLoading || newValue == '') { return; }
        if (g_user.get(country) === 'Country A') {
            g_form.removeOption('issue_type', 'Change');
        } else if (g_user.get(country) === 'Country B') {
            g_form.removeOption('issue_type', 'Incident');
        }
    }- UI Policy (Optional): You could use a UI policy to show/hide a "Change Details" section based on the selected issue_type.
- 
Performance:Ensure that your scripts are efficient, especially if you have many choice options.
- 
User Experience:Provide clear feedback to the user about why certain options are hidden or displayed.
- 
Testing:Thoroughly test your implementation to ensure it works correctly across different user profiles and locations.
