• onCollect
  • NEWBIE
  • 0 Points
  • Member since 2006

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 9
    Replies
i am inserting custom fields from SF. if the field is empty / null i get nullable object must have a value error. i want to retrieve empty/ non empty values from  SF.
what can be done to prevent this error?
 
appreciate your help.
 
thanks
 
Hi,
 
I am inserting field values from SF to my SQL server. Some of my custom fields are empty.
As a result when using binding.Query(to retrieve fields ) it's giving me following error.
 
failed here
Nullable object must have a value.
 
i am using following code to prevent the program from crashing. But its not working.
 

If contact.User_ID__c.Value = False Then

contact.User_ID__c = ""

contact.User_ID__cSpecified = True

cmd.Parameters.AddWithValue("@UserId", contact.User_ID__c)

Else

cmd.Parameters.AddWithValue("@UserId", contact.User_ID__c)

contact.User_ID__cSpecified = True

End If

 
suggestions..
thanks

Hi,

I am having problem inserting records into the Contact's Objects. I am able to insert one record at a time. Any suggestions??

following is the code i am using for my inserts.

thanks

Private Sub InsertSF()

Dim str As String

Dim cons(0) As sObject

str = "select * from vwInsertToSalesForce where InsertToSF = '0' "

cmd = New SqlCommand(str, con)

con.Open()

dtr = cmd.ExecuteReader

Try

While dtr.Read()

Dim contact As Contact

 

For j As Integer = 0 To cons.GetUpperBound(0)

'For j As Integer = 0 To cons

'Declare a new contact object to hold our values

contact = New Contact

Console.WriteLine("the dtr value is " & dtr(j))

contact.PhysicianID__c = Convert.ToString(dtr("PhysicianId"))

contact.PhysicianID__cSpecified = True

contact.Salutation = Convert.ToString(dtr("Salutation"))

contact.FirstName = Convert.ToString(dtr("FirstName"))

contact.LastName = Convert.ToString(dtr("LastName"))

cons(j) = contact

Next

End While

' con.Close()

'Dim sr() As SaveResult = binding.create(cons)' call the create method passing the arry of tasks as sobjects

Dim sr() As SaveResult = binding.create(cons)

For j As Integer = 0 To sr.GetUpperBound(0)' loop throught the results looking for errors and successes

Console.WriteLine(sr.GetUpperBound(0))

Console.WriteLine("item: " & (j))

If sr(j).success Then

Console.WriteLine("a contact was created with an id of : " & sr(j).id)

dtr.Close()

str = "update vwInsertToSalesForce " & _

"set InsertToSF = '1'" & _

"where InsertToSF = '0' "

 

 

cmd = New SqlCommand(str, con)

cmd.ExecuteNonQuery()

con.Close()

 

 

End If

Next

con.Close()

Catch ex As Exception

Console.WriteLine(vbCrLf & "failed here " & vbCrLf & ex.Message)

Console.Write(vbCrLf & "Hit return to continue...")

End Try

End Sub

Hi,
I am trying to update custom field (i.e. . testID as number) in the Contact object using a call back store procedure. Code works fine but doesn't update the field . Below is my code. Any suggestions??
i have permission to modify the data.
thanks
 
 
 

contact.testID__c = CDbl(cmd.Parameters("@NewId").Value)

Dim saveResults() As SaveResult = binding.update(New sforce.sObject() {contact})

For j As Integer = 0 To saveResults.GetUpperBound(0)

Console.WriteLine("Item: " & j)

If saveResults(j).success Then

Console.WriteLine("An account with an id of: " & saveResults(0).id & " was updated." & vbCrLf)

Else

Console.WriteLine("Item " & j & " had an error updating.")

Console.WriteLine(" The error reported was: " & saveResults(j).errors(0).message & vbCrLf)

End If

Next

i am inserting custom fields from SF. if the field is empty / null i get nullable object must have a value error. i want to retrieve empty/ non empty values from  SF.
what can be done to prevent this error?
 
appreciate your help.
 
thanks
 

Hi,

I am having problem inserting records into the Contact's Objects. I am able to insert one record at a time. Any suggestions??

following is the code i am using for my inserts.

thanks

Private Sub InsertSF()

Dim str As String

Dim cons(0) As sObject

str = "select * from vwInsertToSalesForce where InsertToSF = '0' "

cmd = New SqlCommand(str, con)

con.Open()

dtr = cmd.ExecuteReader

Try

While dtr.Read()

Dim contact As Contact

 

For j As Integer = 0 To cons.GetUpperBound(0)

'For j As Integer = 0 To cons

'Declare a new contact object to hold our values

contact = New Contact

Console.WriteLine("the dtr value is " & dtr(j))

contact.PhysicianID__c = Convert.ToString(dtr("PhysicianId"))

contact.PhysicianID__cSpecified = True

contact.Salutation = Convert.ToString(dtr("Salutation"))

contact.FirstName = Convert.ToString(dtr("FirstName"))

contact.LastName = Convert.ToString(dtr("LastName"))

cons(j) = contact

Next

End While

' con.Close()

'Dim sr() As SaveResult = binding.create(cons)' call the create method passing the arry of tasks as sobjects

Dim sr() As SaveResult = binding.create(cons)

For j As Integer = 0 To sr.GetUpperBound(0)' loop throught the results looking for errors and successes

Console.WriteLine(sr.GetUpperBound(0))

Console.WriteLine("item: " & (j))

If sr(j).success Then

Console.WriteLine("a contact was created with an id of : " & sr(j).id)

dtr.Close()

str = "update vwInsertToSalesForce " & _

"set InsertToSF = '1'" & _

"where InsertToSF = '0' "

 

 

cmd = New SqlCommand(str, con)

cmd.ExecuteNonQuery()

con.Close()

 

 

End If

Next

con.Close()

Catch ex As Exception

Console.WriteLine(vbCrLf & "failed here " & vbCrLf & ex.Message)

Console.Write(vbCrLf & "Hit return to continue...")

End Try

End Sub

Hi,
I am trying to update custom field (i.e. . testID as number) in the Contact object using a call back store procedure. Code works fine but doesn't update the field . Below is my code. Any suggestions??
i have permission to modify the data.
thanks
 
 
 

contact.testID__c = CDbl(cmd.Parameters("@NewId").Value)

Dim saveResults() As SaveResult = binding.update(New sforce.sObject() {contact})

For j As Integer = 0 To saveResults.GetUpperBound(0)

Console.WriteLine("Item: " & j)

If saveResults(j).success Then

Console.WriteLine("An account with an id of: " & saveResults(0).id & " was updated." & vbCrLf)

Else

Console.WriteLine("Item " & j & " had an error updating.")

Console.WriteLine(" The error reported was: " & saveResults(j).errors(0).message & vbCrLf)

End If

Next

Hi !

I create an object and specify a particular Field.
For exemple I create an Opportunity, specifying the description field.
The object is well created and the description field is set to a value.

When I update this object, I can change the value of the field without any problem.
But if the new value is null (typicaly an empty Textbox), the field is not set to null on update,
containing the same value as before the update !!!

I tried this:
if (DescriptionBox.Text.Length == 0)
    MyOpportunity = null;

Doesn't work :(

Any idea about my problem ?
Thank you in advance.
Matthias.