You need to sign in to do that
Don't have an account?
Insert Contact not working
Hi all,
This is my first post here. I am also brand new to SalesForce. I just started messing with the SalesForce web services. I can login and run some simple queries with no problems. Now, I want to insert a new contact into my salesforce database. I am using vb.net. Here is my code:
Private Sub InsertNewContact()
Try
If Not login() Then
Return
End If
Dim cons(1) As sforce.sObject
Dim contact As New sforce.Contact
Dim j As Integer
For j = 0 To cons.GetUpperBound(0)
Next
If Not accounts Is Nothing Then
contact.AccountId = accounts(0)
End If
contact.AssistantName = "Jane"
contact.AssistantPhone = "777.777.7777"
contact.Department = "IT"
contact.Description = "Software Developer"
contact.Email = "bh0526@netzero.com"
contact.Fax = "555.555.5555"
contact.MailingCity = "Boca Raton"
contact.MailingCountry = "US"
contact.MailingState = "FL"
contact.MailingStreet = "1907 NE 2nd St"
contact.MailingPostalCode = "33441"
contact.MobilePhone = "888.888.8888"
contact.FirstName = "Bob"
contact.LastName = "Herrmann"
contact.Salutation = "Mr."
contact.Phone = "999.999.9999"
contact.Title = "Software Developer"
cons(1) = contact
Dim sr() As sforce.SaveResult = binding.create(cons)
Catch Ex As Exception
Response.Write(Ex.Message)
End Try
End Sub
I never get an error. But if I go into salesforce.com I do not see this new contact. Can anyone tell me what I'm doing wrong?
Thanks,
Bob
Thanks for the reply Simon. I checked the success code like you suggested and it came back true. But I do not see my contact in SalesForce.
Thanks,
Bob
Oh yeah, I did. I forgot to mention that. It was a long value with a mixture of letters and numbers.
Thanks,
Bob
Simon,
I'm a little confused. I did a response.write for these values after I save. Here is my code for this:
Response.Write(sr(0).success.ToString & " " & sr(0).id & "<br>")
This returns: True 00330000006Er2TAAS
So what is this url you want me to check? Do I plug in my returned value in place of newid?
Thanks,
Bob
Sorry, I was using http: instead of https:. So this is what I get when I go to this site with my newid:
The data you were trying to access could not be found. It may be due to another user deleting the data or a system error. If you know the data is not deleted but cannot access it, please look at our support page.
I first get the login screen and then a page with the above error appears.
I may have mistyped it. But now I can see my contact. In fact, I see about 10 of them since they were posting over and over as I was testing. I like this web service. I can now create a web page that lists our accounts and contacts from our legacy app and allow the users to update our SalesForce data. Another question: our users use www.salesforce.com. I notice my insert went to na1.salesforce.com. Is this just for testing?
Thanks,
Bob
Everything is ok now. Please disregard my last post. What happenend was that I registered as system admin in sales force using .com on my email and then registered using .net on my email for a developer. I made them both the same and now I can see my new contact. Thanks for all your help!!
Bob