You need to sign in to do that
Don't have an account?
Ben Males
How do I alert selected picklist value
Hi All,
I'm trying to alert the User when a particualr value is selected within a picklist.
In Object Manager I have the Standard Object, Case
And in the Case Standard Object I have the Case Reason with the field label and field name Case Reason and Reason respectively with the type Data Type picklist.
Within the picklist I have the Case Reason Picklist Values such as Accounts, ALL - Bank Holiday Routing etc.
On the Case Page Layout I have added a Visualforce Page and what I'm trying to do is to alert / popup a warning if the User selects a particular value - example Apex below
Any help greatly appreciated.
I'm trying to alert the User when a particualr value is selected within a picklist.
In Object Manager I have the Standard Object, Case
And in the Case Standard Object I have the Case Reason with the field label and field name Case Reason and Reason respectively with the type Data Type picklist.
Within the picklist I have the Case Reason Picklist Values such as Accounts, ALL - Bank Holiday Routing etc.
On the Case Page Layout I have added a Visualforce Page and what I'm trying to do is to alert / popup a warning if the User selects a particular value - example Apex below
<apex:page standardController="Case"> <apex:outputText id="myScript"> <script> if(!Case.Reason == "ALL - Bank Holiday Routing") { window.alert("Alert"); } </script> </apex:outputText> <apex:form > <apex:inputField value="{!Case.Reason}"> <apex:actionSupport event="onselect" reRender="myScript"/> </apex:inputField> </apex:form> </apex:page>However, currently nothing is displayed to the User so how can I display an alert when the User selects a value?
Any help greatly appreciated.
You do not need to call the server instead use the script (javascript) to handle at the client (browser) end. Try this and it will help for sure:
Thanks
Gulshan Raj (https://forceblazer.com/)
Thank you for the Reply.
Unfortunately when selecting Other there is still no alert to the User. Is there an alternative suggestion to try?
Kind regards
I'm using the latest version of Chrome (Version 97.0.4692.99 (Official Build) (64-bit)) which does support JavaScript as if I have a simple JS alert in the vf page it works.
Below is the Apex for this alert
This alert fires onLoad, but I want to alert onChange when the user selects a value like "Other" in your example code but the alert doesn't display using that example code.
Kind regards
I think you are missing something. When I use the same code it works without any issue in the same browser.
Nevermind your browser supports javascript that is what I want to know.
Can you please try this code. Make sure the line I hightlight should be there.
I want to check two things:
Thanks
Gulshan Raj (https://forceblazer.com/)
Thank you for your continued feedback.
As you suspected the event is not getting fired as there is nothing in the console when changing the value(s).
Kind regards