5

I have a requirement of showing a pop up (soft error) that will show a message when account information is not filled in the page. This is a salesforce standard page and hence there is no VF code written. I wrote the below inline VF and inserted it in the page layout but it is not showing the alert message. Could you kindly advice if anything is wrong ?

<apex:page standardController="Event_Cost__c" rendered="{!Event_Cost__c.Account__c == ' '}">
    <script type="text/javascript">
        { window.alert("You have not selected Account"); }
    </script>
</apex:page>
1
  • Try rendered="{! ISBLANK(Event_Cost__c.Account__c) }"; your present code seems to be checking to see if the value is a single character string containing a space.
    – Keith C
    Aug 8, 2014 at 8:59

2 Answers 2

3

Here's a different approach altogether to use that requires no code

  1. Create a custom formula field called 'Alerts'
  2. Add to a section with 1 column - and don't display header on edit or view
  3. Use the following formula pattern (done on an Opportunity)

The example will display a little red/yellow/green flag plus text whenever either field Foo__c is empty/'TBD' or the parent Account is missing the market/geo/region/billingCountry.

The approach has limitations in that the formula field can't be more than 5000 characters compiled but for a limited set of soft alerts, it works great and can be customized point-and-click

    /* Form of an alert is a set of concatenated strings as follows:

    IF(<condition 1>,
       IMAGE("/img/samples/flag_yellow|red|green.gif" , 'Yellow|Red|Green' ,12,12) & ' alert text with leading space' & BR() ,
       NULL
    ) &
    next condition as above for second alert */

    IF (OR(ISPICKVAL( Foo__c,"TBD"),ISPICKVAL(Foo__c,"")),
        IMAGE("/img/samples/flag_yellow.gif" , 'Yellow' ,12,12) & ' Foo is not set to Yes or No' & BR(),
        NULL)
    &
    IF (OR(ISPICKVAL( Account.Geo__c, ""),
           ISPICKVAL(Account.Market__c,""), 
           ISPICKVAL( Account.Region__c , ""), 
           ISBLANK(Account.BillingCountry)),
       IMAGE("/img/samples/flag_red.gif" , 'Red' ,12,12) & ' One or more of Account Geo/Region/Country/Market is blank. Update on the Account tab. Required for reporting' & BR(),
    NULL)

Here's an example (redacted) from one of my standard page layouts

enter image description here

1

I don't think you have direct access to the fields on the standard page. Try adding the fields as hidden input. Something like this, would pop up whenever the record is viewed and saved:

<apex:page standardController="Event_Cost__c" tabStyle="Event_Cost__c" >
  <apex:form >
    <apex:inputHidden value="{!Event_Cost__c.Account__c}" id="account"/>
  </apex:form>
  <script language="javascript">
     var acct;
     acct=document.getElementById('j_id0:j_id1:account').value;
     window.onload = function() {
       if (acct.length===0) {
         alert("Warning, the record was saved without an Account!");
       }
     }
  </script>
</apex:page>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .