function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
rmcubedrmcubed 

problems creating contracts (VB.NET)

first post to this forum! I am seeing some odd behaviour when trying to create a contract. Basically, a whole bunch of fields do not show up with values, even though no error is generated, and I can see the values prior to the create call.

For example, the contract created by my test case below does not end up having a start date or an end date or a contract term. In more complex examples, it also applies to some of my custom fields. Can anyone verify this on their set-up, and/or suggest any solutions?

Here's the code:

Private Sub btnTest_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTest.Click
Dim sfSession As sforce.SforceService
Dim sfcs(0) As sforce.Contract
Dim sfR(0) As sforce.SaveResult
sfcs(0) = New sforce.Contract
sfcs(0).Name = "Test contract"
sfcs(0).StartDate = #1/1/2004#
sfcs(0).ContractTerm = 24
'use any known AccountID here
sfcs(0).AccountId = "001200000022brN"
'use your own values for the login
sfSession = Login(txtSFUsername.Text, txtSFPassword.Text)
sfR = sfSession.create(sfcs)
If sfR(0).success Then
Trace.WriteLine("Success - ID " & sfR(0).id)
Else
Trace.WriteLine("Failure: " & sfR(0).errors(0).message)
End If
MsgBox("Complete")
End Sub
Private Function Login(ByVal Username As String, ByVal Password As String) As sforce.SforceService
Dim sfSession As New sforce.SforceService
Dim objSFloginRes As sforce.LoginResult
objSFloginRes = sfSession.login(Username, Password)
sfSession.SessionHeaderValue = New sforce.SessionHeader
sfSession.SessionHeaderValue.sessionId = objSFloginRes.sessionId
sfSession.Url = objSFloginRes.serverUrl
Return sfSession
End Function
DevAngelDevAngel
Hi rmcubed,

In .NET you need to set an additional property for intrinsic data types. You'll notice that your StartDate field has a "sister" field called StartDateSpecified. Setting that field to true while also setting your StartDate field will cause correct create/update behavior.
rmcubedrmcubed
Thanks. "Intrinsic types" in this context basically means any non-string type, right?



DevAngel wrote:
Hi rmcubed,

In .NET you need to set an additional property for intrinsic data types. You'll notice that your StartDate field has a "sister" field called StartDateSpecified. Setting that field to true while also setting your StartDate field will cause correct create/update behavior.


DevAngelDevAngel
Hmm.. I guess.

What I mean is types in .net that can't be set to null.
SuperfellSuperfell
ValueTypes in .NET speak.