You need to sign in to do that
Don't have an account?

Clearing Date/Time Field (VB.NET)
I referred to the following post regarding clearing a date field and changed it for VB but I cannot seem to get the date field to clear.
http://forums.sforce.com/sforce/board/message?board.id=NET_development&message.id=2627&query.id=5521#M2627
Here is a subset of my test code:
'-- Create Opportunity Record
Dim objOpp As New Opportunity
objOpp.Id = sMyID
objOpp.Name = "Testing"
'-- Specify fields to null
'-- NEW CODE START
Dim aNull(1) As String
aNull(0) = "CloseDate"
aNull(1) = "Credit_Report_Date__c"
objOpp.fieldsToNull = aNull
'-- NEW CODE END
'-- Add this Opportunity to the array to send to SF
Dim aobjOpps() as sObject
aobjOpps(0) = objOpp
'-- Call Update
Dim aobjSaveResult() As SaveResult = Nothing
aobjSaveResult = myBinding.update(aobjOpps)
This is a trimmed down version of the acutal code. Everything is working just fine for updates and has been for months. I've simply attempted to add the logic to null out certain fields. Here's what happens/doesn't happen:
- The code runs without error
- The update occurs
- Save result reflects success
- The fields are not nulled
I'm sure I'm just missing something simple but I can't figure out what!
Thank you for any insight -
Lisa
http://forums.sforce.com/sforce/board/message?board.id=NET_development&message.id=2627&query.id=5521#M2627
Here is a subset of my test code:
'-- Create Opportunity Record
Dim objOpp As New Opportunity
objOpp.Id = sMyID
objOpp.Name = "Testing"
'-- Specify fields to null
'-- NEW CODE START
Dim aNull(1) As String
aNull(0) = "CloseDate"
aNull(1) = "Credit_Report_Date__c"
objOpp.fieldsToNull = aNull
'-- NEW CODE END
'-- Add this Opportunity to the array to send to SF
Dim aobjOpps() as sObject
aobjOpps(0) = objOpp
'-- Call Update
Dim aobjSaveResult() As SaveResult = Nothing
aobjSaveResult = myBinding.update(aobjOpps)
This is a trimmed down version of the acutal code. Everything is working just fine for updates and has been for months. I've simply attempted to add the logic to null out certain fields. Here's what happens/doesn't happen:
- The code runs without error
- The update occurs
- Save result reflects success
- The fields are not nulled
I'm sure I'm just missing something simple but I can't figure out what!
Thank you for any insight -
Lisa
Did you set CloseDateSpecified field when updating ?
Thanks,
Chitra
CloseDate: invalid date: Sat Jan 01 00:00:00 GMT 1
Help SimonF!!
Thank you -
Lisa
other than that, can't see anything wrong, are you sure the fieldsToNull is not getting wiped out further on in the code you don't show ?
Thank you Simon -
Lisa
Dim aNull(1) As String
aNull(0) = "Credit_Report_Expiration_Date__c"
aNull(1) = "Credit_Report_Date__c"
objLoan.Credit_Report_Expiration_Date__cSpecified = False
objLoan.Credit_Report_Date__cSpecified = False
objLoan.fieldsToNull = aNull
Thank you for explicitly stating that! Yeah, it was specified, but it was specified WRONG!
Thanks Simon!
Lisa