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
zeezackisbackzeezackisback 

Creating a task priority object on home page.

What would be the html/javascript to create a list of priority tasks on the home page. What javascript would I use to connect to the salesforce table and then pull down the results?

 

 

<html> <head> <script> function GetPriorityTask() { result = sforce.connection.query("Select Id from Case'"); var records = result.getArray("records"); if (records.length != 1) { alert("An error occurred"); } else { alert(records[0]); } } </script> </head> <body> <script> GetPriorityTask(); </script> </body> </html>

 

 

werewolfwerewolf

May I suggest that you do this in Visualforce instead?  Seems like this guy did something similar (in the first post).

 

 

zeezackisbackzeezackisback

How do you go about adding a visual page to the home page?

 

Also how do I go about tackling this objective?

zeezackisbackzeezackisback

I can't get the visualforce to work.

 

All I need is the ability to display a table of data, relating to only priority tasks.

 

zeezackisbackzeezackisback

It seems that the apex code in the tutorials only works an ID is captured on the page....

 

All I want to do on this home page is list the tasks with high priority?

 

zeezackisbackzeezackisback

public class MyHighTask { private final TaskPriority task; public MyHighTask () { task = [select Id, IsHighPriority from TaskPriority where IsHighPriority= true]; } public TaskPriority getHighTask () { return task ; } }

 

zeezackisbackzeezackisback

http://www.salesforce.com/us/developer/docs/pages/Content/pages_quick_start_component_library.htm

 

This claims you need to have the visualforce page hooked up to an id...in order for the code to work?

zeezackisbackzeezackisback

<apex:page controller="MyHighTask"> <apex:pageBlock title="Hello {!$Task.task }!"> This is your new page. </apex:pageBlock> </apex:page>

 

Surely to call the function in apex there would be something like

 

 

<apex:page controller="MyHighTask"> <apex:pageBlock"> This is your new page and this is the variable {getHighTask();}. </apex:pageBlock> </apex:page>

 

 

werewolfwerewolf
What you need is something that uses a Set controller and not just a regular controller.  Look that up in the Apex docs.
zeezackisbackzeezackisback

Dear Werewolf,

please elaborate. 

 

You mean something like this?

 

 

Problem
You want to display a set of records in a table in a Visualforce page.
Solution
Define a custom controller that returns the set of records you want to display, and then use
the <dataTable> tag to display the results.
Discussion
To illustrate this example, let's first modify the sample controller that we defined in Creating
Your First Visualforce Controller on page 258 so that it returns a list of associated contacts with
an account record:

 

 

public class mySecondController { public Account getAccount() { return [select id, name, (select id, firstname, lastname from Contacts limit 5) from Account where id = :System.currentPageReference().getParameters().get('id')]; } public String getName() { return 'My Second Custom Controller'; } }

 

 

 

 

Now iterate over the resulting contacts with the <dataTable> tag. This tag allows us to define
an iteration variable that we can use to access the fields on each contact:

 

 

<apex:page controller="mySecondController" tabStyle="Account"> <apex:pageBlock title="Hello {!$User.FirstName}!"> You belong to the {!account.name} account. </apex:pageBlock> <apex:pageBlock title="Contacts"> <apex:dataTable value="{!account.Contacts}" var="contact" cellPadding="4" border="1"> <apex:column>{!contact.FirstName}</apex:column> <apex:column>{!contact.LastName}</apex:column> </apex:dataTable> </apex:pageBlock> </apex:page>

 

 

 

 

 

 

but again it requries an ID to work?