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
Aidel BruckAidel Bruck 

How to create an alert with a visual force page

I am assuming that what I trying to do is pretty basic, I am just fairly new to visual force

I would like an alert to show if a certain condition is met. In this alert I would like to have input fields that can be saved to the record. 

I created this visual force page, but it is not an alert. 
How can I make it into an alert?

<apex:page standardController="Comment__c" rendered="{!if(Comment__c.Care_Management_Related2__c==true,true,false)}">
<apex:form >
        <apex:pageBlock title="Enter Care Management Call Details">
            <apex:pageBlockSection title="Next Suggested Call" columns="1">
                <apex:inputField value="{!Comment__c.Next_Suggested_Call_Date__c}"
                label="next suggested call date"/>
                <apex:inputText value="{!Comment__c.Next_Suggested_Call_Description__c}"
                    label="Next Suggested Call Description"/>
            </apex:pageBlockSection>
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>
Dushyant SonwarDushyant Sonwar
Hi Aidel ,

You can do something like this below for js alert.
<script>
function test(){
	if({!Comment__c.Care_Management_Related2__c}){
		alert('condition is true , showing javascript alert');
	}
}

window.onload = test;
</script>

Final code would after adding would be something like this below.
<apex:page standardController="Comment__c" rendered="{!if(Comment__c.Care_Management_Related2__c==true,true,false)}">
<script>
function test(){
	if({!Comment__c.Care_Management_Related2__c}){
		alert('condition is true , showing javascript alert');
	}
}

window.onload = test;
</script>

<apex:form >
        <apex:pageBlock title="Enter Care Management Call Details">
            <apex:pageBlockSection title="Next Suggested Call" columns="1">
                <apex:inputField value="{!Comment__c.Next_Suggested_Call_Date__c}"
                label="next suggested call date"/>
                <apex:inputText value="{!Comment__c.Next_Suggested_Call_Description__c}"
                    label="Next Suggested Call Description"/>
            </apex:pageBlockSection>
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Hope this helps!
mr dhonimr dhoni
Follow the below steps to implement this solution. by unlockmytv (https://unlockmytv.fun/)
I have created a custom field on Account object with data type checkbox. The field name is “Display_Alert__c”
Create a visual force page “AccountAlertLayoutPage” to display alert.
I created this page with below code.
<apex:page standardController="Account"> <script> if({!Account.Display_Alert__c}) alert('Display Alert!!'); </script> </apex:page>
Next go to Account page Layout and add visualforce page created above to the Account PageLayout.
get more information on https://www.salesforcetutorial.com/alert-salesforce-standardcustom-object-page-layouts/