You need to sign in to do that
Don't have an account?
Can only add text fields when creating a new lead using API
I am using the following code:
Public Sub CreateLead()
Dim lead1 As New Lead()
' Set some fields on the lead object.
lead1.FirstName = "John"
lead1.LastName = "Langlois"
lead1.Email = "john@longnecksolutions.com"
lead1.Company = "No Company"
Dim ourDouble As Double = 10
lead1.Contract_Amount__c = ourDouble
Dim strMonth As String = DatePart("m", Now())
Dim strDay As String = DatePart("d", Now())
Dim strYear As String = DatePart("yyyy", Now())
Dim strHour As String = DatePart("h", Now())
Dim strOurdate As String
Dim strHalf As String
If strHour > 12 Then
strHour = strHour - 12
strHalf = "PM"
Else
strHalf = "AM"
End If
Dim strMin As String = DatePart("m", Now())
strOurdate = strMonth & "/" & strDay & "/" & strYear & " " & strHour & ":" & strMin & " " & strHalf
lead1.Received_Contract__c = strOurdate
lead1.Alt_Email__c = "me2@Alt.com"
' Create an array of SObjects to hold the leads
Dim leads As sObject() = New sObject(0) {}
' Add the leads to the SObject array
leads(0) = lead1
' Invoke the create() call
Try
Dim saveResults As SaveResult() = binding.create(leads)
' Handle the results
For i As Integer = 0 To saveResults.Length - 1
' Determine whether create() succeeded or had errors
If saveResults(i).success Then
' No errors, so retrieve the Id created for this record
Response.Write("A Lead was created with Id: " & saveResults(i).id & "<br>")
Else
Response.Write("Item " & i & " had an error updating<br>")
' Handle the errors
For Each [error] As [Error] In saveResults(i).errors
Response.Write("Error code is: " & [error].statusCode.ToString() & "<br>")
Response.Write("Error message: " & [error].message & "<br>")
Next
End If
Next
Catch e As SoapException
Response.Write(e.Code)
Response.Write(e.Message)
End Try
End Sub
The text fields are adding with the new record but the other fields, date and currency.... are not.
What amI doing wrong?
John
All Answers