+ Start a Discussion
Eric Anderson 54Eric Anderson 54 

Best practice for handling notifications in Visualforce

HI there,

I am new to Salesforce and consiquently Visualforce. I have a business requirement to notify the user if they have not selected the correct entry i the drop down box. I've tried to apply information related in the following 'Article' with no success:

https://developer.salesforce.com/forums/ForumsMain#!/feedtype=SINGLE_QUESTION_SEARCH_RESULT&id=906F00000008x3BIAQ

The article was based on how to display a 'Message box' in Visualforce. I know the condition to display the message box is met, but the Message box is not being displayed, I am able to see that the value in 'results' is infact equal to true because of the information shown in the log. My related code is below:

RELEVANT VISUALFORCE CODE
 
<apex:page standardController="Request__c" extensions="TrController" >
    <!-- The following code will fix a problem with the calendar autospawning when the time entries are displayed. -->
    <script>
        function setFocusOnLoad(){ Coment.focus(); }
    </script>
    <script> 
       	function validateRecords()
       	{
           	if('{!results}' == true)
               {
                   alert('Please select a action type for the record entered and then click on "Save" again!');
			   }                    
 		}
    </script>



RELEVANT CONTROLLER CODE
 
public string results {get;set;}
    public TrController(ApexPages.StandardController controller) 
    {
        //Obtain the parent object Id from the the visualforce form. 
        ReqId = Apexpages.currentPage().getparameters().get('Id');
        //SelectedEntryId = Apexpages.currentPage().getparameters().get('deleteEntryId');
        //Call the loaddata method to laod the time entries related to the parent object. 
        results = LoadData();
     }
    public string LoadData()
    {
        //Establish results indicator
        results = 'False';
        //Obtain the first 15 bytes of the Parent Object ID to use for record selection. 
        string RequestID = ReqId.substring(0, 15);
        //Load the related time entry records from the database. 
        TimeEntries = [select id, Activity__c, Date_Worked__c, Hours_Worked__c, Minutes_Worked__c, Work_Description__c from Time_Entry__c WHERE Related_Object__c=:RequestID order by ID DESC]; 
        for(Time_Entry__c a : TimeEntries)
        {
        if (a.Activity__c == '<Select Activity>')
            {
                results = 'True';
            }
        } 
        System.debug(results);
        return results;
        //return;
    }

    public void add()
    {   
       //Obtain the first 15 bytes of the Parent Object ID to use for record identification. 
        string RequestID = ReqId.substring(0, 15);
        //Build the default values to the new time entry record. 
        Time_Entry__c entry = new Time_Entry__c(Activity__c='<Select Activity>', Date_Worked__c=System.today(), Hours_Worked__c=' 0', Minutes_Worked__c='00', Related_Object__c=RequestID);
        //Insert the new default time entry row into the Salesforce database. 
        Insert entry;
        //Call the method to reload the Visualforce list. 
        results = LoadData();
        //LoadData();
        //return;
    }

I would greatly appreciate any guidance on how best to proceed with my Visualforce code prompting the user to select an appropriate entry in the drop down box.

Thank you!

Eric Anderson
Best Answer chosen by Eric Anderson 54
Eric Anderson 54Eric Anderson 54
Though my user is EXTREMELY unhappy with the fact that I can not get a 'Message' box to pop up, my manager directed me to abort my efforts trying to get it to work and go with the solution documented in this post instead.

https://developer.salesforce.com/forums/?id=906F00000008mMjIAI

The good news is that my manager backed me up in this case, but he will only be here for another week so after that, I will be back at the mercey of the end users and no back up. :-(