You need to sign in to do that
Don't have an account?
rulichny
Getting Started - Web application to fill dropdown list with Salesforce Opportunities
Hi,
I have what appears to be a rather straightforward task but since I'm new to both .NET Web development and salesforce.com, I figured I'd ask before I get started.
We are creating a Web application that needs to show users a list of Salesforce Opportunities and allow them to make a selection. The selection will be stored in our own SQL Server tables along with other non salesforce related data that is entered on the screen.
Is this doable? From what I am reading I need to create and download the enterprise.wsdl. I also saw sample applications but wasn't sure which one was most appropriate for my needs. We are using vb.NET and Visual Studio 2003 Enterprise edition for our development.
Thanks in advance for your help.
I have what appears to be a rather straightforward task but since I'm new to both .NET Web development and salesforce.com, I figured I'd ask before I get started.
We are creating a Web application that needs to show users a list of Salesforce Opportunities and allow them to make a selection. The selection will be stored in our own SQL Server tables along with other non salesforce related data that is entered on the screen.
Is this doable? From what I am reading I need to create and download the enterprise.wsdl. I also saw sample applications but wasn't sure which one was most appropriate for my needs. We are using vb.NET and Visual Studio 2003 Enterprise edition for our development.
Thanks in advance for your help.
Protected WithEvents Opportunities As System.Web.UI.WebControls.DropDownList
Private Sub (etc....)
'Do our login, Create the session
Dim SSO_Service As New Sforce_Account_Lookup.SforceService
Dim lr As Sforce_Account_Lookup.LoginResult
Dim dlr As Sforce_Account_Lookup.DescribeLayoutResult
'Username and password are stored in the web.config appsettings
Dim strUserName = ConfigurationSettings.AppSettings("Sforce_Username").ToString()
Dim strPassword = ConfigurationSettings.AppSettings("Sforce_Password").ToString()
lr = SSO_Service.login(strUserName, strPassword)
SSO_Service.Url = lr.serverUrl
SSO_Service.SessionHeaderValue = New Sforce_Account_Lookup.SessionHeader
SSO_Service.SessionHeaderValue.sessionId = lr.sessionId
'Create our QueryResult
Dim qrOpps As New Sforce_Account_Lookup.QueryResult
'Hit the API for open Opportunities
qrOpps = SSO_Service.query("SELECT Name, Id FROM Opportunity WHERE IsClosed != true")
'Add them to our Dropdownlist
For k As Integer = 1 To qrOpps.size
iRecord = k - 1
Dim li As New ListItem
li.Text = qrOpps.records(iRecord).Any(0).InnerText
li.Value = qrOpps.records(iRecord).Any(1).InnerText
Opportunities.Items.Add(li)
Next
End Sub
I cut and pasted your code but I received an error when trying to build the app:
'Any' is not a member of 'WebApplication1.sforce.sObject'.
The error is being produced on line with following code:
li.Text = qrOpps.records(iRecord).Any(0).InnerText
I apologize if this is a dumb question but can you please assist. Thanks.
Rich
As it turns out, I will need to show the customer a list of Accounts (not Opportunities) in the drop down box. Once an Account is selected, I am going to fill another dropdown box with Open Opportunities for that Account (using the Account ID from the first selection).
Should I do that via a Query or I've read somewhere that if I have the ID, I should do a Retrieve instead. Anyone have sample code for that?
Also, the customer has about 6,000 accounts and filling a dropdown list with that could be a problem. I seem to time out about half the time. Any suggestions for working around that? Perhaps I can ask them to type in a partial Account name before I go and grab the list of Accounts using the LIKE option in my WHERE clause. Also, since the list comes back unsorted (and there is no 'order by' option from what I can see) I assume I'll have to do some sort with my app. Does anyone have a sample for that?
Thanks
For sorting, you can do a number of things. Commonly, you'll probably find one of these two:
1. Take the results and load them into a dataset create a dataview for the dataset and sort that. Nice if you're using .Net datagrids and don't have a lot of results.
2. You can use an arraylist and sort the arraylist. That code would be something like what's below, but in truth I didn't compile it to test it out. Oh, and this will only create a sorted arraylist. You will need to loop through the list and split it on the ":" to populate your dropdown.
Dim itemsArray As ArrayList
If (qrMyQuery.size > 0) Then
For i As Integer = 0 To qrMyQuery.size - 1
itemsArray.Add(qrMyQuery.records(i).Any(1).InnerText & ":" & qrMyQuery.records(i).Any(0).InnerText)
Next
itemsArray.Sort()
End If
As far as returning 6000+ rows and sorting them, is it easy to put them into a Datagrid/Dataset? As you can tell by my questions, .NET development is new to me.
Since I don't plan to show the results via a datagrid I assume I would just make that invisible to the customer and use it for sorting, etc. I would then need to add those sorted results to my dropdown list. Does that sound like what you are suggesting?
How's that sound?
As a result, I am creating a simple VB.NET application (not web app) that can be scheduled to run nightly and pull the necessary data from Account and Opportunity. Once the data is in our tables, we can sort it and present it to the customer via a dropdown and other search options as previously discussed.
So far I've written the code to pull the Account info as needed. Seems fairly straightfoward as we only need a few fields from the table. If I hit any snags I'm sure I'll post other questions! Thanks for your help.
Bill Emerson
www.forceAmp.com