+ Start a Discussion
We have apex classes through which we send emails based on user action in force.com sites. It was working great until Friday, But yesterday when one of our customer try to submit application, they were getting error, In debug it says “SendEmail failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, INVALID_TYPE: sObject type 'SalesforceIqDataSource' is not supported.: []”. I am pretty sure we did not change anything related to apex class, email template, vf page etc.. Does anyone know the reason or best way to fix this?
Best Answer chosen by SandyMeda
Signagelive DevelopmentSignagelive Development
Following on from Andrew's comment about Salesforce whitelisting the SalesforceIqDataSource for the site guest user I put in a ticket with Salesforce Support explaining the situation.

They whitelisted the SalesforceIqDataSource object for the site guest user for our organisation and I can confirm this has resolved the issue for us.

Therefore, for anyone still encountering this issue I was advise that you do the same thing and raise a ticket with Salesforce support.

Thanks everyone for the support on this.
Daniel BallingerDaniel Ballinger 
The WSDL generated for an Apex Class method using the webservice keyword may be missing required complex types.

Take the example:
global class RetrieveOpportunity {
  webservice static Opportunity retrieveOpportunity(Id opportunityId) {
    return new Opportunity();

This will generate a WSDL with elements like:
<xsd:element name="BillingAddress" minOccurs="0" type="tns:address" nillable="true"/>

The issue is that there is no address complex type in the WSDL tns namespace (http://soap.sforce.com/schemas/class/DFB/RetrieveOpportunity in this case).

This results in errors like:
Error: type 'address@http://soap.sforce.com/schemas/class/RetrieveOpportunity' not found.
Source - WSDL generated from apex can't import to SoapUI (http://salesforce.stackexchange.com/q/56005/102)
Error 1 Unable to import binding 'getLeadInfoBinding' from namespace 'http://soap.sforce.com/schemas/class/getLeadInfo'. App_WebReferences/WebReference/

Source - Issue with Adding reference Webservice WSDL to VS2010 (http://salesforce.stackexchange.com/q/53329/102)

The currently solution is to manually add the missing complex types to the xsd:schema with the required targetNamespace.
<!-- Compound datatype: Address -->
        <complexType name="address">
                <extension base="tns:location">
                        <element name="city" type="xsd:string"  nillable="true" />
                        <element name="country" type="xsd:string"  nillable="true" />
                        <element name="countryCode" type="xsd:string"  nillable="true" />
                        <element name="postalCode" type="xsd:string"  nillable="true" />
                        <element name="state" type="xsd:string"  nillable="true" />
                        <element name="stateCode" type="xsd:string"  nillable="true" />
                        <element name="street" type="xsd:string"  nillable="true" />

<!-- Compound datatype: Location -->
        <complexType name="location">
                <element name="latitude" type="xsd:double"  nillable="true" />
                <element name="longitude" type="xsd:double"  nillable="true" />

Can this be raised as an Apex API bug?
Best Answer chosen by Daniel Ballinger
ShashankShashank (Salesforce Developers) 
Hi Daniel,

This has already been published as a known issue and can be tracked here: https://success.salesforce.com/issues_view?id=a1p300000008XKUAA2
Nevin O'Regan 3Nevin O'Regan 3 
Hi All,

I'm trying to source a formula that works correctly. I need to display the period between two date fields in Words (Year(s), Month(s), Day(s).
I have found a number of suggessted formulas here and also I have been offered solutions here but they don't seem to work with all date periods. For example, I have a Lease Start Date 01.12.2018 and a Lease End Date 30.11.2021. I was using a formula which was suggested to me in the past but it returns a value of 3 Years, - 1 Month, 29 Days when it should be 2 Years 11 Months 29 Days.
The formula that I have used is below. Maybe it needs some kind of adjustment, I don't really know. 


TEXT(Year(  TODAY()  )- Year(  Start_Date1__c  )) &" "&"Years"&" "&
TEXT(Month(  TODAY()  )-Month(  Start_Date1__c  )) &" "&"Months"&" "&
TEXT(Day(  TODAY()  )-Day(  Start_Date1__c  ))&" "&"Days",

TEXT(Year(  End_Date__c  )- Year(  Start_Date1__c  )) &" "&"Years"&" "&
TEXT(Month(  End_Date__c  )-Month(  Start_Date1__c  )) &" "&"Months"&" "&
TEXT(Day(  End_Date__c  )-Day(  Start_Date1__c  ))&" "&"Days")
Best Answer chosen by Nevin O'Regan 3
Alain CabonAlain Cabon
Hi Nevin,

This problem is not so easy in fact and many solutions on the internet are not accurate (approximations with modulos 365 and 30). 

I "solved" the problem with two formulas and the recoding of the javascript engine used here:   http://www.calculconversion.com/calculateur-date.html

This javascript engine widely used is here:  https://gist.github.com/adamphillips/612587

It is a quick javascript dateDiff function that returns results in terms of days, months and years taking into account variable month lengths and leap years.

I used two formulas but that is not mandatory.

1)  last_day_next_month__c:  
IF(MONTH(date1__c)=12,DATE(YEAR(date1__c)+1,1,1)-1, DATE(YEAR(date1__c),MONTH(date1__c) + 1,1) -1)

2)  The formula to display the period between two date fields in Words (Year(s), Month(s), Day(s).
IF ( day(date2__c) - day(date1__c) < 0, 
IF( month(date2__c) - month(date1__c) -1 < 0, 
"d1: " & TEXT( YEAR(date2__c) - YEAR(date1__c) -1) & " years " & 
TEXT( MONTH(date2__c) - MONTH(date1__c) +11) & " months " & 
TEXT( DAY(date2__c) - DAY(date1__c) + DAY( last_day_next_month__c )) & " days", 

"d2: " & TEXT( YEAR(date2__c) - YEAR(date1__c)) & " years " & 
TEXT( MONTH(date2__c) - MONTH(date1__c) -1) & " months " & 
TEXT ( DAY(date2__c) - DAY(date1__c) + DAY( last_day_next_month__c )) & " days"), 

IF( month(date2__c) - month(date1__c) < 0, 
"d3: "& TEXT( YEAR(date2__c) - YEAR(date1__c) -1) & " years " & 
TEXT( MONTH(date2__c) - MONTH(date1__c) +12) & " months " & 
TEXT( DAY(date2__c) - DAY(date1__c)) & " days", 

"d4 :" & TEXT( YEAR(date2__c) - YEAR(date1__c)) & " years " & 
TEXT( MONTH(date2__c) - MONTH(date1__c)) & " months " & 
TEXT ( DAY(date2__c) - DAY(date1__c)) & " days") 

You can copy paste the defintion of last_day_next_month__c into the formula above.

2018-10-10 - 2021-10-10  =>  3 Y  - 0 M  - 0 D  (d4)

2018-10-10 - 2021-05-05 =>   2 - 6 - 26  (d1)
2018-05-10 - 2021-10-05  => 3 - 4 - 26  (d2)
2018-10-05 - 2021-05-10  => 2 - 7 - 5   (d3)
2018-05-05 - 2021-10-10  => 3 - 5 - 5   (d4)

User-added image

2018-12-01 - 2021-11-30 => 2 - 11 - 29 (d3)

 Start Date 01.12.2018 and a Lease End Date 30.11.2021 = 2 Years 11 Months 29 Days.

We can continue more tests even the first results above are all accurate.
farouk fakunlefarouk fakunle 
Has anyone completed this trail? I am stomped on challenge number 3, regarding created the process for fulfillment. Any pointers or guidance would be appreciated.
Best Answer chosen by farouk fakunle
farouk fakunlefarouk fakunle
@Ajay thanks for your input,  Here is my data model below.  Thanks to @Trupti @Fons @ Jennifer @Surlya @ Nikhil for the valuable input and assistance on STEP 4

I am referencing the Adventure Pakage Object to Start my process so it it is:

Object - Adventure Package
Start Process- Only when a record is created 


Define Criteria for this Action Group 

Criteria for Executing Actions - Conditions are met 

Set Conditions:

1. [OpportunityLineItem].Oppotunity.StageName Does not equal Cancelled 
2. [OpportunityLineitem].Fulfillment_Created_c Equals False

Conditions - All of the conditions are met (AND) 


1. Create a Record 

Record Type - Fulfillment 

Set Field Values 

AdventurePackageId -  Reference -[OpportunityLineItem].Id
Adventure Package cost - Reference - [OpportunityLineItem].TotalPrice 
Adventure - Reference -  [OpportunityLineItem].Product2Id
Expedition Leader - Reference -[OpportunityLineItem].Product2.Expedition_Leader_c
Explorer - Reference - [OpportunityLineItem].Explorer_C
Fulfillment Name - Formula -[OpportunityLineItem].Product2.Name + [OpportunityLineItem].Id
Schedule Date -Reference - [OpportunityLineItem].ServiceDate
Status- Picklist - New 
Package -  [OpportunityLineItem].OpportunityId

2. Update Records

Record - [OpportunityLineItem].Opportunity ID 

No criteria just update records 

Set new fields for the records you update 

Needs Insurance - Reference- [OpportunityLineItem].Product2.Needs_Insurance_c
Needs waiver - Reference -  [OpportunityLineItem].Product2.Needs_Waiver_c

3. Update Records 

Record - [OpportunityLineItem]

Criteria for Updating Records - No criteria-just update records 

Set new field values for the records you update 

Fulfilment Created = True 
Needs Insurance - Reference- [OpportunityLineItem].Product2.Needs_Insurance_c
Needs waiver - Reference -  [OpportunityLineItem].Product2.Needs_Waiver_c

Evaluate the Next Criteria 



Define Criteria for this Action Group 

Criteria for Executing Actions - Conditions are met 

Set Conditions:

1. [OpportunityLineItem].Explorer_c   Is Null  = True 

Conditions - All of the conditions are met (AND)


Create a Record - Task 

Set Field Values

Assigned to ID - reference- [OpportunityLineItem].Opportunity.OwnerId
Related to ID - reference -[OpportunityLineItem].Opportunity.Id
Priority - Normal 
Status - Not started 
Subject- String - Update explorer 


14 days from now 

Post to Chatter 

User - Select a user from a record - [OpportunityLineItem].Opportunity.Owner.Id





Once done with these changes, execute blow lines of code in dev console.

Product2 product = new Product2(name='Half Dome Hike', isActive=true); 
insert product; 
//insert the pricebookentry 
Pricebook2 stdPrice = [Select id from Pricebook2 where isStandard=true limit 1]; 
PricebookEntry pbe = new PricebookEntry( IsActive = true, Product2Id = product.id, UnitPrice = 2.00, Pricebook2Id = stdPrice.Id); 
insert pbe;
rima khanrima khan 
I registered with trailhead.
I’m an SDR looking to expand my Salesforce skill set. Let’s pretend I have none. Particularly looking for the basics around reporting, and any other trails that may be beneficial to spend some time with.
My goal is to have a competent understanding of SF to build my sales as I enter a closing role and the relevant tools in SF that will help me gain an advantage.
Thanks in advance!
Best Answer chosen by rima khan
manasa udupimanasa udupi
Hi Rima,

Below are few trailhead links, hope it helps:)

New to Salesforce so I'm sorry if this is a dumb question. But I'm trying to write a trigger to help set some required fields on our Case object when we receive an email using email to case. I just can't understand why the trigger isn't firing in my debug logs.
trigger TestEmail2Case on EmailMessage (before insert, before update) {
    for(EmailMessage e : trigger.new) {
        system.debug(LoggingLevel.INFO, '>>>>> email:' + e);

​I've read a couple other instances of people using the before insert on email message to help tie into email to case but it just doesn't seem to be firing for me. Any help would be apprecited. Thanks!
Best Answer chosen by \dev\null
I ended up moving this discussion to SE

Hi I am looking for a easy way to print or export a large Field Dependency matrix in excel. I am new to saleforce please guide me with complete details.
Best Answer chosen by nksf
Unfortunately field dependencies are not records that we can manipulate via Data Loader or Import/Export with the Wizard that Salesforce.com has available.
 Field dependencies are part of the Metadata which cannot be manipulated via standard functionality.

I would like to suggest you to take a look to the following options:

First the link to the PDF File that contains all the necessary information to be able to handle the Metadata API that Salesforce has available:

Also, there are other 3rd party application which allows you to export the data so it may help you to achieve what you need. An example of this application: http://appexchange.salesforce.com/listingDetail?listingId=a0N300000018leZEAQ

A last option might be to look at the Force.com Migration tool to export the Metadata, manipulate the appropriate Metadata XML files by hand and then migrate over back to your Production instance.
Guiomar Fernández de BobadillaGuiomar Fernández de Bobadilla 

I have this error when I try to check challenge:

Challenge Not yet complete... here's what's wrong: 
Could not find an account named 'Blackbeards Grog Emporium' created from Workbench with the Description 'The finest grog in the seven seas.'

In the next picture you can see what I send by the Workbench

User-added image

The result is succes and in my Developer Org I can see the Account created correctly, but the challenge isn't passed.
Best Answer chosen by Guiomar Fernández de Bobadilla
Guiomar Fernández de BobadillaGuiomar Fernández de Bobadilla
I've created other Account with the same Name and Description, so now I've the Account twice (but different ids) and now I passed the challenge! I don't know why.

In the Trailhead with SOAP Ui (https://developer.salesforce.com/trailhead/force_com_dev_intermediate/api_basics/api_basics_soap) occurs the same. It's necessary create two Accounts to pass the challenge.
Nico AnicaNico Anica 
I am trying to display some information but everytime I have this following message error :
SObject row was retrieved via SOQL without querying the requested field: Contact.Client_a_risque__c

Here below is my code : 

Class Name      : CCF_CustomContactSearch
Description     : This page will be open by InIn on an Agent's browser, once a Case is 
                  assigned to the Agent. 
                  When loaded, the page will contain a list of Contacts 
                  possibly matching to a value (svalue) contained in the URL as a parameter
                  The Agent also has the option to search for a specific contact, using the
                  input field beside "Search Contact" button. The value provided in the input 
                  field will be searched in ALL fields in the Contact Object
                  For every listed Contact, the Agent has the option lo link it to the Case,
                  using "Link to Case" button
Created By      : Mihai JURIAN
Created Date    : 30-Jan-17
Modification Log:
Developer                   Date                   Description
Mihai Jurian            30-Jan-17                   Initial Version
<apex:page controller="CCF_searchContactController" docType="html-5.0" action="{!search_onLoad}" title="{!$Label.InIn_Recherche_de_contact}">

    <apex:includeScript value="/support/console/28.0/integration.js"/>
    <script type="text/javascript">
        function openCaseDetails() {
            sforce.console.openPrimaryTab(undefined, '/{!caseId}', true, '{!caseNumber}');

        // The callback function that closeTab will call once it has the ID for its tab
        var callCloseTab = function callCloseTab(result) {
        function closeTab() {
        var pageLoad = window.onload;
        window.onload = function() 
            if (pageLoad) 
    <apex:form >
        <apex:actionFunction name="updateSortOrderBy1" action="{!updateSortOrderBy}">
            <apex:param id="updateOrderBy" name="updateOrderBy" value="" />
        <apex:actionFunction name="search_method" action="{!search_method}" />

        <apex:input value="{!searchValue}" id="searchValue"/>
        <apex:commandButton value="{!$Label.InIn_Trouver_le_Contact}" onclick="search_method(); return false;" />
        <apex:outputText id="searchWarning" value="Please enter at least 2 characters before searching." rendered="{!showSearchWarning}" />
        <apex:pageBlock title="Contacts" id="block">
            <apex:inputCheckbox value="{!excludeHasFilter}"  onclick="search_method();" />
            <apex:outputText >{!$Label.CCF_CustomSearch_IncludeAllRecords}</apex:outputText>
            <apex:pageMessages />
            <!-- the Pagination/Navigation buttons -->
            <apex:pageBlockButtons rendered="{!RenderNavigation}" location="bottom"> 
                <apex:commandButton value="{!$Label.navigationFirst}" action="{!first}" disabled="{!DisablePrevious}"/>
                <apex:commandButton value="{!$Label.navigationPrevious}" action="{!previous}" disabled="{!DisablePrevious}"/>
                <apex:commandButton value="{!$Label.navigationNext}" action="{!next}" disabled="{!DisableNext}"/>
                <apex:commandButton value="{!$Label.navigationLast}" action="{!last}" disabled="{!DisableNext}"/>
            <!-- the table showing the Contacts -->
            <apex:pageblockTable id="contactList" value="{!conListToShow}" var="con">
                <apex:column >
                    <apex:facet name="header">
                        <apex:commandLink action="{!updateSortOrderBy}" value="{!$ObjectType.Contact.fields.Name.Label + IF(orderBy == 'Name', '▼', IF(orderBy == 'Name DESC', '▲', ''))}" >
                            <apex:param name="updateOrderBy" value="Name" assignTo="{!updateOrderBy}"/>
                    <apex:outputLink value="/{!con.Id}" id="theLink">{!con.name}</apex:outputLink>
                <apex:column >
                    <apex:facet name="header">
                        <apex:commandLink action="{!updateSortOrderBy}" value="{!$ObjectType.Contact.fields.Birthdate.Label + IF(orderBy == 'Birthdate', '▼', IF(orderBy == 'Birthdate DESC', '▲', ''))}" >
                            <apex:param name="updateOrderBy" value="Birthdate" assignTo="{!updateOrderBy}"/>
                    <apex:outputfield value="{!con.Birthdate}"/>
                <apex:column >
                    <apex:facet name="header">
                        <apex:commandLink action="{!updateSortOrderBy}" value="{!$ObjectType.Contact.fields.Phone_1__c.Label + IF(orderBy == 'Phone_1__c', '▼', IF(orderBy == 'Phone_1__c DESC', '▲', ''))}" >
                            <apex:param name="updateOrderBy" value="Phone_1__c" assignTo="{!updateOrderBy}"/>
                    <apex:outputfield value="{!con.Phone_1__c}"/>
                <apex:column >
                    <apex:facet name="header">
                        <apex:commandLink action="{!updateSortOrderBy}" value="{!$ObjectType.Contact.fields.Phone_2__c.Label + IF(orderBy == 'Phone_2__c', '▼', IF(orderBy == 'Phone_2__c DESC', '▲', ''))}" >
                            <apex:param name="updateOrderBy" value="Phone_2__c" assignTo="{!updateOrderBy}"/>
                    <apex:outputfield value="{!con.Phone_2__c}"/>
                <apex:column >
                    <apex:facet name="header">
                        <apex:commandLink action="{!updateSortOrderBy}" value="{!$ObjectType.Contact.fields.Phone_3__c.Label + IF(orderBy == 'Phone_3__c', '▼', IF(orderBy == 'Phone_3__c DESC', '▲', ''))}" >
                            <apex:param name="updateOrderBy" value="Phone_3__c" assignTo="{!updateOrderBy}"/>
                    <apex:outputfield value="{!con.Phone_3__c}"/>
                <apex:column >
                    <apex:facet name="header">
                        <apex:commandLink action="{!updateSortOrderBy}" value="{!$ObjectType.Contact.fields.Email_1__c.Label + IF(orderBy == 'Email_1__c', '▼', IF(orderBy == 'Email_1__c DESC', '▲', ''))}" >
                            <apex:param name="updateOrderBy" value="Email_1__c" assignTo="{!updateOrderBy}"/>
                    <apex:outputfield value="{!con.Email_1__c}"/>
                <apex:column >
                    <apex:facet name="header">
                        <apex:commandLink action="{!updateSortOrderBy}" value="{!$ObjectType.Contact.fields.Email_2__c.Label + IF(orderBy == 'Email_2__c', '▼', IF(orderBy == 'Email_2__c DESC', '▲', ''))}" >
                            <apex:param name="updateOrderBy" value="Email_2__c" assignTo="{!updateOrderBy}"/>
                    <apex:outputfield value="{!con.Email_2__c}"/>
                <apex:column >
                    <apex:facet name="header">
                        <apex:commandLink action="{!updateSortOrderBy}" value="{!$ObjectType.Contact.fields.Agency_PIN__c.Label + IF(orderBy == 'Agency_PIN__c', '▼', IF(orderBy == 'Agency_PIN__c DESC', '▲', ''))}" >
                            <apex:param name="updateOrderBy" value="Agency_PIN__c" assignTo="{!updateOrderBy}"/>
                    <apex:outputfield value="{!con.Agency_PIN__c}"/>
                <apex:column >
                    <apex:facet name="header">
                        <apex:commandLink action="{!updateSortOrderBy}" value="{!'Record Type' + IF(orderBy == 'RecordType.Name', '▼', IF(orderBy == 'RecordType.Name DESC', '▲', ''))}" >
                            <apex:param name="updateOrderBy" value="RecordType.Name" assignTo="{!updateOrderBy}"/>
                    <apex:outputfield value="{!con.RecordType.Name}"/>
                <apex:column >
                    <apex:facet name="header">
                        <apex:commandLink action="{!updateSortOrderBy}" value="{!$ObjectType.Contact.fields.Client_a_risque__c.Label + IF(orderBy == 'Client_a_risque__c', '▼', IF(orderBy == 'Client_a_risque__c DESC', '▲', ''))}" >
                            <apex:param name="updateOrderBy" value="Client_a_risque__c" assignTo="{!updateOrderBy}"/>
                    <apex:outputfield value="{!con.Client_a_risque__c}"/>
                <!-- the buttons "Link to Case" -->
                <apex:column headervalue="{!$Label.Link_to_Case}">
                    <apex:commandButton value="{!$Label.Link_to_Case}" action="{!linkContactToCase}" rerender="block" oncomplete="openCaseDetails()">
                        <apex:param name="theContactId" value="{!con.Id}" assignTo="{!contactId}"/>

Best Answer chosen by Nico Anica
Deepali KulshresthaDeepali Kulshrestha
Hi Nico,

You are getting this error because you are not querying this field 'Client_a_risque__c' which is in your Contact Object.
If Contact is your parent object then you should use this 'Contact.Client_a_risque__c' in your query in Controller named 'CCF_searchContactController'.

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Deepali Kulshrestha
Angela DomingoAngela Domingo 
I am working on Admin Beginner Lightning Experience Customization Set Up Your Org module (https://trailhead.salesforce.com/trails/force_com_admin_beginner/modules/lex_customization/units/lex_customization_custom_objects?trailmix_creator_id=00550000006yDdKAAU&trailmix_id=prepare-for-your-salesforce-administrator-credential) and have completed all the steps to create the objects and when clicking on the "check challenge" button, it returns the error: "Challenge Not yet complete... here's what's wrong: Could not find the 'Audit_Notes__c' field on the custom object named 'Energy_Audit__c'."
Screenshot of verification error in Trailhead for Set Up Your Org module

I have gone back into the Trailhead Playground that I used and verified that the field does exist and is related and on the custom object as I had set it up.
Energy Audit Object screenshot
Screenshot of Audit Notes related field

I can't get past this challenge and it won't complete this module unless it is verified. Is anyone else running into this?  I have successfully had all the previous challenges completed and this is the first time I got an error that I can't figure out what is missing.

Thanks in advance for your help.
Best Answer chosen by Angela Domingo
Check that FLS is correct for the field

User-added image
Also make sure the field is on all your Energy Audit page layouts