• JamesT77
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 5
    Replies

hi

 

i've read up on how you can test callout code (Virtual Callout Testing) and tried to use it within a trigger.

 

However this code does not work when you try to call it within a trigger.

 

To fire the callout method within the trigger you have to fire it asynchronously using the @Future tag and the method has to be static also. This breaks the virtual classes. 

 

Has anyone got the Virtual Callout Testing code to work within a trigger also?

i get the following error when i try to use fieldsToNull on a Lead
 

87:Email Opt Out: value not of required type: {0}

 
i would love to know where im going wrong
 
here is the code
 

'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

 
 
Hi
 
I have a strange problem with loging using the enterprise web service.
 
I created a new test website and using the .net examples managed to login and did some various tasks with the api
 
Now i have moved this code into our development website im getting the error message below when i try to login.
 
"No connection could be made because the target machine actively refused it".
 
The code in either project is identical but in the test website login is successfull and in the development website it is unsucessfull.
 
The difference between them is that the test website is a file system website running through VS own web server and the development website is on my local iis.
 
Is it a problem with firewall settings?
 
do i have to open a port for the apex api webservice to connect? and if i do what is the port?


Message Edited by JamesT77 on 07-24-2008 05:58 AM
im getting the following error when i try to login
 
Unable to generate a temporary class (result=1).
error CS2001: Source file 'C:\WINDOWS\TEMP\oqt-a62h.0.cs' could not be found.
 
the error is on the following line of code within 

Public Class EnterpriseLoginBean

    Public Sub initByUsername()

        salesForceService = New SforceService()
 
 
i get the following error when i try to use fieldsToNull on a Lead
 

87:Email Opt Out: value not of required type: {0}

 
i would love to know where im going wrong
 
here is the code
 

'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

 
 
Hi
 
I have a strange problem with loging using the enterprise web service.
 
I created a new test website and using the .net examples managed to login and did some various tasks with the api
 
Now i have moved this code into our development website im getting the error message below when i try to login.
 
"No connection could be made because the target machine actively refused it".
 
The code in either project is identical but in the test website login is successfull and in the development website it is unsucessfull.
 
The difference between them is that the test website is a file system website running through VS own web server and the development website is on my local iis.
 
Is it a problem with firewall settings?
 
do i have to open a port for the apex api webservice to connect? and if i do what is the port?


Message Edited by JamesT77 on 07-24-2008 05:58 AM
im getting the following error when i try to login
 
Unable to generate a temporary class (result=1).
error CS2001: Source file 'C:\WINDOWS\TEMP\oqt-a62h.0.cs' could not be found.
 
the error is on the following line of code within 

Public Class EnterpriseLoginBean

    Public Sub initByUsername()

        salesForceService = New SforceService()