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
IZavalunIZavalun 

UPSERT casted string to Double always put '0' PLEASE HELP

PLEASE HELP...
I have custom object in SalesForce.com 'TH_Revenue_Totals__c' with 2 currency fields ''Sell_In_Total__c' and 'Sell_Through_Total__c'.
 
When using upsert I am casting the string values to Double but it's always 0 in my custom object.
PLEASE HELP....
----------------------------------------------------------------

Private Sub UpsertToSalesForce(ByVal OwnerId As String, _

ByVal Sell_In_Total__c As String, _

ByVal Sell_Through_Total__c As String, _

ByVal Sell_In_Goal__c As String, _

ByVal Sell_Through_Goal__c As String, _

ByVal strExternalID__c As String)

 

Dim sforce As New sforce.SforceService

Dim ur As sforce.UpsertResult()

Dim recordsToUpdate As sforce.sObject()

Dim aryList As System.Collections.ArrayList

aryList = New ArrayList()

Dim i As Integer

Dim revenue As New sforce.TH_Revenue_Totals__c

revenue.OwnerId = OwnerId

'revenue.Sell_In_Total__c = CType(Sell_In_Total__c, Double)

'revenue.Sell_Through_Total__c = CType(Sell_Through_Total__c, Double)

revenue.Sell_In_Total__c = CDbl(Sell_In_Total__c)

revenue.Sell_Through_Total__c = CDbl(Sell_Through_Total__c)

revenue.Sell_In_Goal__c = Sell_In_Goal__c

revenue.Sell_Through_Goal__c = Sell_Through_Goal__c

revenue.ExternalID__c = strExternalID__c

aryList.Add(revenue)

recordsToUpdate = aryList.ToArray(GetType(sforce.sObject))

Try

ur = binding.upsert("ExternalID__c", recordsToUpdate)

For i = 0 To ur.Length - 1

If ur(i).success Then

Console.WriteLine("Upsert is Successful..." & "Status: " & ur(i).created)

Else

Console.WriteLine("Upsert failed, id: " & ur(i).id())

End If

Next i

Catch ex As Exception

Console.WriteLine("Error in: " & "UpsertToSalesForce(): " & ex.Message)

Finally

End Try

End Sub

SuperfellSuperfell
You need to add
revenue.Sell_In_Total__cSpecified = true

and the same for the other double fields.
IZavalunIZavalun

IT WORKS !!!!

Thank you very much!!!!!