You need to sign in to do that
Don't have an account?
AnnieG
Scontrol: QueryResult.loadSelectElement function
Hi,
Anyone who has the experience of using the QueryResult.loadSelectElement function please take a look at my code:
function setup() {
var queryResult = sforceClient.query("Select Id, LastName, FirstName From Lead ");
// var t1 = document.getElementById("select1");
queryResult.loadSelectElement("select1", true, "id", "LastName","FirstName LastName ");
}
<select id ="select1" >
</select>
According to http://blog.sforce.com/sforce/2006/04/ajax_toolkit_be.html, Want to create a drop down list (select element) from the results of a query? No problem. Just run your query and call the QueryResult's loadSelectElement method. This method takes the id of your select element and populates the options collection from the query result. You specify which field is used the option value, which field or fields to use for the display values, whether you want the list sorted or not and optionally how you want the display values formated.
But I can't get my code to work, any suggestion? Thanks a lot for your sharing!
Annie
Anyone who has the experience of using the QueryResult.loadSelectElement function please take a look at my code:
function setup() {
var queryResult = sforceClient.query("Select Id, LastName, FirstName From Lead ");
// var t1 = document.getElementById("select1");
queryResult.loadSelectElement("select1", true, "id", "LastName","FirstName LastName ");
}
<select id ="select1" >
</select>
According to http://blog.sforce.com/sforce/2006/04/ajax_toolkit_be.html, Want to create a drop down list (select element) from the results of a query? No problem. Just run your query and call the QueryResult's loadSelectElement method. This method takes the id of your select element and populates the options collection from the query result. You specify which field is used the option value, which field or fields to use for the display values, whether you want the list sorted or not and optionally how you want the display values formated.
But I can't get my code to work, any suggestion? Thanks a lot for your sharing!
Annie
What error if any are you getting?
To use this method you need to add ?browser=true to the url for the toolkit.
<script language="javascript" src="https://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js?browser=true" type="text/javascript"></script>
Cheers
Thanks for your reply!
Yes, I have included the exact script line in my code.
I have not got any error message, but my drop down list hasn't been populated with the options retrived from the query result. That is to say the list is empty.
Just don't know why.
Thanks again!
Annie
Try running this as an html page from your local drive. When the page loads, enter your user name and password. After succussful login select case from the list of record types.
The second list uses the loadSelectElement function.
Code:
Thanks for your help and code!
If I understand you correctly, I should copy your code and make it a s-control (saved as an html file) in my sandbox and activate it with a link or a tab, right? So I did. And I wasn't prompted for the user name and password since I logged in. But the lists are empty.
Am I following you? Thanks again!
Without getting the loadSelectElement method to work, I had to write javascript functions to implement the whole algorithm, like putting together and sort an two dimenssional array, it worked. But I still hope there is a better solution.
This is a test file that I've used in the past and is not really meant to do anything other than verify that it works.
Cheers
I did what you tell me to. Save it as an html file, launch it from windows explorer, but it just shows two empty lists with a button, not even prompting me to log in. When I click the button, the lists are not populated. Am I doing wrong again? Thanks!
There was no error message when I launch the page either from FireFox or IE. Thanks!
I'll try and get your query to work and send you the snippet.
Cheers
I've included an scontrol body that has an override for the loadSelectElement function that sorts properly based on the option text of the resultant select element. Also are a couple examples of how the super simple formatting works.
Cheers.
Code:
Let me know if it works for you. Steve.
Code:
By the way Annie, a more detailed example and explanation of my code changes is here:
http://community.salesforce.com/sforce/board/message?board.id=ajax_toolkit&message.id=626&query.id=14838#M626
Good luck, Steve.