You need to sign in to do that
Don't have an account?
problem with fieldsToNull
87:Email Opt Out: value not of required type: {0}
'update this lead
Dim sr As sforce.SaveResult = [Global].AppBinding.update(New sforce.Lead() {LeadFromForm(userID)})(0)
Private Function LeadFromForm(ByVal userID As Int32) As Lead
Dim sfdcLead As New Lead()
Dim fieldsToNullString As New List(Of String)
Dim checkBoxFieldName As String = String.Empty
With sfdcLead
'Online Shop purchase
If _registrationType = RegistrationTypes.OnlineShop Then
.Online_Shop_Purchase__c = _registrationType = RegistrationTypes.OnlineShop
.Online_Shop_Purchase__cSpecified = .Online_Shop_Purchase__c.Value
Else
fieldsToNullString.Add("Online_Shop_Purchase__c")
End If
'Lead Channel
.Lead_Channel__c = "Web"
'PR USER ID
If userID > 0 Then .PR_User_ID__c = userID.ToString
If sfdcLeadID.Length > 0 Then .Id = sfdcLeadID
If salutationDropDownList.SelectedIndex > 0 Then .Salutation = salutationDropDownList.SelectedItem.Text.Trim
.FirstName = firstNameTextBox.Text.Trim
.LastName = lastNameTextBox.Text.Trim
.Company = companyNameTextBox.Text.Trim
.Brand_Division__c = brandDivisionTextBox.Text.Trim
.Title = jobTitleTextBox.Text.Trim
Dim street As String = addressLine1TextBox.Text.Trim.Replace("""", "") & " " & addressLine2TextBox.Text.Trim.Replace("""", "") & " " & addressLine3TextBox.Text.Trim.Replace("""", "")
.Street = street
.City = cityTextBox.Text.Trim
.PostalCode = zipPostalCodeTextBox.Text.Trim
.State = stateCountyProvinceTextBox.Text.Trim
.Country__c = countryDropDownList.SelectedItem.Text.Trim
.Email = emailAddressTextBox.Text.Trim
.Phone = contactTelephoneNumberTextBox.Text.Trim
.Website = companyWebsiteTextBox.Text.Trim
.Function__c = jobFunctionDropDownList.SelectedItem.Text.Trim
.Level_in_Hierarchy__c = jobHierarchyDropDownList.SelectedItem.Text.Trim
'check retail sector interest
For Each RSIItem As ListItem In retailSectorInterestCheckBoxList.Items
If RSIItem.Selected = True Then
Select Case RSIItem.Text.ToLower
Case "consumer electronics"
.Consumer_Electronics__c = Convert.ToBoolean(RSIItem.Selected.GetHashCode)
.Consumer_Electronics__cSpecified = .Consumer_Electronics__c.Value
checkBoxFieldName = "Consumer_Electronics__c"
Case "department stores"
.Department_Stores__c = Convert.ToBoolean(RSIItem.Selected.GetHashCode)
.Department_Stores__cSpecified = .Department_Stores__c.Value
checkBoxFieldName = "Department_Stores__c"
Case "drugstore / pharmacies"
.Drugstore_Pharmacy__c = Convert.ToBoolean(RSIItem.Selected.GetHashCode)
.Drugstore_Pharmacy__cSpecified = .Drugstore_Pharmacy__c.Value
checkBoxFieldName = "Drugstore_Pharmacy__c"
Case "entertainment goods (dvds, books, cds)"
.Entertainment__c = Convert.ToBoolean(RSIItem.Selected.GetHashCode)
.Entertainment__cSpecified = .Entertainment__c.Value
checkBoxFieldName = "Entertainment__c"
Case "grocery"
.Grocery__c = Convert.ToBoolean(RSIItem.Selected.GetHashCode)
.Grocery__cSpecified = .Grocery__c.Value
checkBoxFieldName = "Grocery__c"
Case "health & beauty"
.Health_Beauty__c = Convert.ToBoolean(RSIItem.Selected.GetHashCode)
.Health_Beauty__cSpecified = .Health_Beauty__c.Value
checkBoxFieldName = "Health_Beauty__c"
Case "hotel / restaurant / catering (horeca)"
.Hotel_Restaurant_Catering__c = Convert.ToBoolean(RSIItem.Selected.GetHashCode)
.Hotel_Restaurant_Catering__cSpecified = .Hotel_Restaurant_Catering__c.Value
checkBoxFieldName = "Hotel_Restaurant_Catering__c"
Case "office supply / stationery"
.Office_Supply__c = Convert.ToBoolean(RSIItem.Selected.GetHashCode)
.Office_Supply__cSpecified = .Office_Supply__c.Value
checkBoxFieldName = "Office_Supply__c"
End Select
Else
fieldsToNullString.Add(checkBoxFieldName)
End If
Next
If CheckDropDownListIsValid(geographicInterestDropDownList) Then .Geographic_Interest__c = geographicInterestDropDownList.SelectedItem.Text.Trim
If Convert.ToBoolean((productInterestDropDownList.SelectedIndex = 1).GetHashCode) Then
.News_eAlert__c = Convert.ToBoolean((productInterestDropDownList.SelectedIndex = 1).GetHashCode)
.News_eAlert__cSpecified = .News_eAlert__c.Value
Else
fieldsToNullString.Add("News_eAlert__c")
End If
If Convert.ToBoolean((productInterestDropDownList.SelectedIndex = 2).GetHashCode) Then
.Subscription_Demo__c = Convert.ToBoolean((productInterestDropDownList.SelectedIndex = 2).GetHashCode)
.Subscription_Demo__cSpecified = .Subscription_Demo__c.Value
Else
fieldsToNullString.Add("Subscription_Demo__c")
End If
'work out which nature of business has been selected
Dim natureOfBusiness As String = String.Empty
If CheckDropDownListIsValid(natureOfYourBusinessRetailerDropDownList) Then natureOfBusiness = natureOfYourBusinessRetailerDropDownList.SelectedItem.Text.Trim()
If nonRetailerRadioButton.Checked Then
If CheckDropDownListIsValid(natureOfYourBusinessNonRetailerDropDownList) Then natureOfBusiness = natureOfYourBusinessNonRetailerDropDownList.SelectedItem.Text.Trim
End If
If natureOfBusiness.Length > 0 Then .Industry_Custom__c = natureOfBusiness
If CheckDropDownListIsValid(annualRevenueDropDownList) Then .Annual_Company_Turnover__c = annualRevenueDropDownList.SelectedItem.Text.Trim
If CheckDropDownListIsValid(numberOfEmployeesDropDownList) Then .Number_of_Employees__c = numberOfEmployeesDropDownList.SelectedItem.Text.Trim
If CheckDropDownListIsValid(budgetDropDownList) Then .Budget_Exists__c = budgetDropDownList.SelectedItem.Text.Trim
If CheckDropDownListIsValid(decisionMakerDropDownList) Then .Budget_Holder_YN__c = decisionMakerDropDownList.SelectedItem.Text.Trim.ToLower = "yes"
If CheckDropDownListIsValid(purchaseTimeTableDropDownList) Then .Purchase_Timescale__c = purchaseTimeTableDropDownList.SelectedItem.Text.Trim
If CheckDropDownListIsValid(howDidYouHearAboutPlanetRetailDropDownList) Then .LeadSource = howDidYouHearAboutPlanetRetailDropDownList.SelectedItem.Text.Trim
If searchEngineDropDownList IsNot Nothing AndAlso searchEngineDropDownList.Style.Count > 0 AndAlso searchEngineDropDownList.Style("display") IsNot Nothing AndAlso searchEngineDropDownList.Style("display").ToLower = "block" AndAlso CheckDropDownListIsValid(searchEngineDropDownList) Then .Search_Engine__c = searchEngineDropDownList.SelectedItem.Text.Trim
.Additional_Information_Comments__c = furtherInformationTextBox.Text.Trim
If receiveInformationCheckBox.Checked = True Then
.HasOptedOutOfEmail = Convert.ToBoolean(receiveInformationCheckBox.Checked)
.HasOptedOutOfEmailSpecified = .HasOptedOutOfEmail.Value
Else
.HasOptedOutOfEmailSpecified = True
fieldsToNullString.Add("HasOptedOutOfEmail")
End If
If userID > 0 Then .fieldsToNull = fieldsToNullString.ToArray
End With
Return sfdcLead
End Function
.HasOptedOutOfEmailSpecified = True
fieldsToNullString.Add("HasOptedOutOfEmail")
either set the field in fieldsToNull, or give it a value and set Specified to true.
Hello Simon
i have removed the line (.HasOptedOutOfEmailSpecified = True) when i need to set the checkbox value to false
but im still getting the same error.