function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Carol McConnellCarol McConnell 

Message Page/Pop-Up when Field is changed to a certain reason

I am completly new to VisualForce pages but what I'm trying to do is to display a message when a field changes to a certain text.  The field is a picklist, so I don't know if that matters.  Here is what I have in my VF page. When I make the change in the field, I'm not getting anything, no error or anything.  This is just a reminder for them to do something after they change the substatus field to Negotiations Complete.

I would appreciate your assistance.

Thanks,
 
<apex:page standardcontroller="Provider_Interactions__c">
<script>
var PIsubstatus = '{!Provider_Interactions__c.Sub_Status__c}';
window.onload = function () {
if(PIsubstatus == 'Negotiations Complete')
{
alert ('Please Update The Fee Schedule Information');
}
}
</script>
</apex:page>

 
SwethaSwetha (Salesforce Developers) 
HI Carol,
The code in https://salesforce.stackexchange.com/questions/180099/how-to-display-alert-popup-based-on-a-value-by-selecting-an-account should help you get started. Happy to help if you are stuck somewhere.

Similar: https://salesforce.stackexchange.com/questions/87917/how-to-display-an-error-message-on-a-visualforce-page-when-a-picklist-value-on-a

If this information helps, please mark the answer as best. Thank you
Carol McConnellCarol McConnell
Swetha,

Okay, so for the VF page:    
I know the "Apex" would be my Custom object.  Can you assist as to where the other fields would go?

My Custom Oject is Provider_Interactions__c
My field is Sub_Status__C
The picklist option that I want the message to display is Negotiations Complete.

I'm just not sure in this code which goes where?

Thanks,
 
<apex:page controller="Apex">    
    <apex:form id="form">
        <apex:pageBlock id="one">
            <apex:selectList size="1" value="{!accid}" id="dropdown_change">
                <apex:selectOptions value="{!records}" />
            </apex:selectList>
            <script>
                const selectEl = document.getElementById('{!$Component.form.one.dropdown_change}');
                function alertBox(){
                    if(selectEl.selectedIndex == 0){
                        alert('Select an account');
                    }
                }
            </script>
            <apex:commandButton value="Submit" reRender="testPanel" onclick="alertBox()" />
            <apex:param value="{!accid}" assignTo="{!accid}"/>
        </apex:pageBlock>
        <apex:outputPanel id="testPanel">
            {!accid}
        </apex:outputPanel>
    </apex:form>
</apex:page>