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
Daven Davis 3Daven Davis 3 

How to add generic error message for if statement visual force page

I am looking to add a generic error message to the following Visual force page so that if not products have been selected on the opportunity display error.  My code has no issues yet does not display anything.  

<apex:page standardController="Opportunity" sidebar="false" > <apex:messages /> <apex:canvasApp namespacePrefix="pactsafe1" developerName="PactSafe_Canvas" width="100%" scrolling="yes" parameters="{ version: 2.0, Opportunity__c: '{! Opportunity.Id }', Account__c: '{! Opportunity.AccountId }', objectPermissions: { PactSafeRequest__c: {! $ObjectType.pactsafe1__PactSafeRequest__c.accessible }, Opportunity: {! $ObjectType.Opportunity.accessible }, Account: {! $ObjectType.Account.accessible }, Contact: {! $ObjectType.Contact.accessible } }, delete: {! NOT( ISBLANK( $CurrentPage.parameters.delID ) ) }, recordType: 'pactsafe1__PactSafeRequest__c', contracts: [ { id: {!IF((Opportunity.Count_of_CP__c > 0),45877,0)}},{ id: {!IF((Opportunity.Count_of_SP__c > 0),45878,0)}},{ id: {!IF((Opportunity.Count_of_RP__c > 0),45904,0)}} , <apex:pageMessages > !IF((Opportunity.Count_of_SP__c < 1 && Opportunity.Count_of_RP__c <1 && Opportunity.Count_of_CP__c <1 ),” No Products have been quoted for this opportunity”,0)}} </apex:pageMessages> ] , }" entityFields="*" /> <!-- Include SDK necessary for JavaScript events between canvas app and this page. --> <apex:includeScript value="/canvas/sdk/js/30.0/controller.js" /> <!-- Define the communicating functions between Pactsafe Canvas App & Salesforce --> <script> /* @description Listens for a pactsafe indicating to redirect the client to the desired url. (Mostly used to redirect to related Object.) </script> </apex:page>
Daven Davis 3Daven Davis 3
This is the code that is being used 

<apex:page standardController="Opportunity" sidebar="false" >
<apex:messages />


    <apex:canvasApp namespacePrefix="pactsafe1" developerName="PactSafe_Canvas"
                    width="100%" scrolling="yes"
                    parameters="{
                                version: 2.0,
                                Opportunity__c: '{! Opportunity.Id }',
                                Account__c: '{! Opportunity.AccountId }',
                                objectPermissions: {
                                   PactSafeRequest__c: {! $ObjectType.pactsafe1__PactSafeRequest__c.accessible },
                                   Opportunity: {! $ObjectType.Opportunity.accessible },
                                   Account: {! $ObjectType.Account.accessible },
                                   Contact: {! $ObjectType.Contact.accessible }
                                },
                                delete: {! NOT( ISBLANK( $CurrentPage.parameters.delID ) ) },
                                recordType: 'pactsafe1__PactSafeRequest__c',
                                
 

contracts: [ { id: 
{!IF((Opportunity.Count_of_CP__c > 0),45877,0)}},{ id: 
{!IF((Opportunity.Count_of_SP__c > 0),45878,0)}},{ id: 
{!IF((Opportunity.Count_of_RP__c > 0),45904,0)}}
,

<apex:pageMessages >

!IF((Opportunity.Count_of_SP__c < 1 && Opportunity.Count_of_RP__c <1 && Opportunity.Count_of_CP__c <1 ),” No Products have been quoted for this opportunity”,0)}}


</apex:pageMessages>

]

}" 
                    entityFields="*" />
    <!-- Include SDK necessary for JavaScript events between canvas app and this page. -->
    <apex:includeScript value="/canvas/sdk/js/30.0/controller.js" />
    
    <!-- Define the communicating functions between Pactsafe Canvas App & Salesforce -->
    <script>
    /*
    @description Listens for a pactsafe indicating to redirect the client to the desired url. 
                 (Mostly used to redirect to related Object.)

  </script>
</apex:page>