• donob
  • NEWBIE
  • 40 Points
  • Member since 2013

  • Chatter
    Feed
  • 1
    Best Answers
  • 1
    Likes Received
  • 1
    Likes Given
  • 3
    Questions
  • 5
    Replies
I'm trying to use a Map to select object fields.  I want to be able to select certain fields and then make queries on those fields.
I use describe to get the fields from selected objects and then put them into a map.  I want to be able to select certain fields and populate them into a correspong map.  

I am trying to use the component found here http://blogs.developerforce.com/developer-relations/2012/06/a-multiselect-picklist-visualforce-component.html but it's not working for my map.  I've tried using a normal selectList and I can display the fields (though it's ugly atm) but after selecting it doesn't populate to the correspoding map.  I've tried using a List as well and got the same results.

My visualforce page here.

<apex:page standardController="Custom_Object__c" extensions="customController">
    <apex:pageBlock >
        <apex:form >
            <apex:commandButton value="Select Objects" action="{!getObjectFields}" rerender="picklists"/>
            <apex:commandbutton value="Get Selected Fields" action="{!printOptions}" rerender="out"/>
           
        <apex:pageBlockSection > 
           
            <c:MultiselectPicklist leftLabel="Objects" leftOptions="{!SupportedObjects}" rightLabel="Objects" rightoptions="{!SelectedObjects}" size="14" width="150px"/>  <!--This works-->
           
        </apex:pageBlockSection>
        </apex:form>
    </apex:pageBlock>

    <apex:pageBlock >
        <apex:form >
        <apex:pageBlockSection  >
            <apex:outputPanel id="picklists">
           
            <apex:repeat value="{!objectFieldMap}" var="key">
                <apex:selectList value="{!selectedFieldsMap[key]}" multiselect="true"><--I can see the fields, but can't populate-->
                    <apex:selectOptions value="{!objectFieldMap[key]}"></apex:selectOptions>
                </apex:selectList>
                <!--<c:MultiselectPicklist leftLabel="Objects" leftOptions="{!objectFieldMap[key]}" rightLabel="Objects" rightoptions="{!selectedFieldsMap[key]}" size="14" width="150px"/> This doesn't work -->
            </apex:repeat>           
            </apex:outputPanel>
           
        </apex:pageBlockSection>
     </apex:form>
    </apex:pageBlock>
</apex:page>

My Controller here

public class customController{
   
    public List<selectOption> supportedObjects {get; set;}//Used for component to get objects -- this works
    public List<selectOption> SelectedObjects {get; set;}//Used for component to get objects -- this works
   
    public Map<String,SelectOption[]> objectFieldMap{get;set;}//<-- This contains all fields for an object
    public Map<String,String[]> selectedFieldsMap{get;set;}//<-- This should receive the selected fields
   
    public List<List<SelectOption>> fieldSelections{get;set;}//<-- This contains all fields for an object when I tried using a list
    public List<List<String>> selectedFields{get;set;}//<--This should receive the selected fields when I tried using a list
   
    Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe(); 
   
    public LookbookCreationController(ApexPages.StandardController stdController){
        SelectedObjects = new List<SelectOption>();
        fieldSelections= new List<List<SelectOption>>();
        init();
    }
   
    private void init(){
   
        supportedObjects = new List<selectoption>();
        Schema.DescribeFieldResult fieldResult = Custom_Object__c.Object__c.getDescribe();//Mulitselect picklist on custom object that has a list of objects to use
        for( Schema.PicklistEntry e : fieldResult.getPicklistValues() ){
            supportedObjects.add( new SelectOption( e.getLabel(), e.getValue() ) );  
        }
    }
   
    public PageReference printOptions(){
        System.debug( selectedFieldsMap );//Using this to see if the map is populated.  
        return null;
    }
   
   
    public void getObjectFields(){
       
        selectedFields = new List<List<String>>();
        objectFieldMap = new Map<String,List<SelectOption>>();
        selectedFieldsMap = new Map<String,List<String>>();

        for(SelectOption o : SelectedObjects){
           
           //Describe stuff to get all fields for the selected Objects. This part works
            List<SelectOption> options = new List<SelectOption>();
            Schema.SObjectType systemObjectType = gd.get(o.getValue());
            Schema.DescribeSObjectResult r = systemObjectType.getDescribe();
            Map<String, Schema.SObjectField> M = r.fields.getMap();
            for( Schema.SObjectField fieldAPI : M.values() ) {
                options.add(new SelectOption(fieldAPI.getDescribe().getName() , fieldAPI.getDescribe().getLabel())) ; 
            } 
            objectFieldMap.put( o.getValue(), options );
            selectedFieldsMap.put( o.getValue(), new List<String>() );
            fieldSelections.add( options );
            selectedFields.add( new List<String>() );
        }
    }


When I use the Map or List, things display but selecting doesn't populate.  Using the component I get the following error Cannot convert the value of '{!leftOptions}' to the expected type. After selecting the objects and trying to display the component.
  • January 23, 2014
  • Like
  • 1

I'm trying to send an email that includes a link to a record in Saleforce using apex email alert and the setHtmlBody method.  I'm trying to send the link like so..

 

<a href="'+URL.getSalesforceBaseUrl()+'/'+workOrder.id+'">'+workOrder.Name+'</a>

 The email gets sent out just fine, but the link isn't there.  When I look at the source in the email it shows the a tag without the href attribute like so...

<a>Work Order Name</a>

 Can anybody tell me why this is happening and what I can do to get the link to work?

  • December 04, 2013
  • Like
  • 0

I am trying to call the webservice and getting the following error:

 

System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: <E97007> The supplied Zip+4 code of '87144' is invalid. faultcode=a:ApplicationException faultactor=

 

I get this error from a class generated from a WSDL in a sandbox org but using a dev org with the same WSDL I get a little more detailed info. 

06:50:06.284 (284395000)|CALLOUT_REQUEST|[197]|
<?xml version="1.0" encoding="UTF-8"?>
	<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
		<env:Header />
		<env:Body>
			<GetAccountDetailsByAccountNumber xmlns="http://tempuri.org/">
				<AccountDetails>
					<AccountNumber xmlns="http://schemas.datacontract.org/2004/07/xxx.xxx.SFDC.Contracts">
						010655421
					</AccountNumber>
				</AccountDetails>
			</GetAccountDetailsByAccountNumber>		
		</env:Body>
	</env:Envelope>

06:50:06.284 (284490000)|CALLOUT_REQUEST|[197]|
GetAccountDetailsByAccountNumber_element:[AccountDetails=GetAccountDetailsByAccountNumberRequest:[AccountNumber=010655421, AccountNumber_type_info=(AccountNumber, http://www.w3.org/2001/XMLSchema, string, 1, 1, true), apex_schema_type_info=(http://schemas.datacontract.org/2004/07/xxx.xxx.SFDC.Contracts, true, false), field_order_type_info=(AccountNumber)], AccountDetails_type_info=(AccountDetails, http://schemas.datacontract.org/2004/07/xxx.xxx.SFDC.Contracts, GetAccountDetailsByAccountNumberRequest, 0, 1, true), apex_schema_type_info=(http://tempuri.org/, true, false), field_order_type_info=(AccountDetails)]::SFDC_STACK_DEPTH=1 SOAPAction="http://tempuri.org/IAccountDetails/GetAccountDetailsByAccountNumber" User-Agent=SFDC-Callout/28.0 Accept=text/xml Content-Type=text/xml; charset=UTF-8 

06:50:07.626 (1626529000)|CALLOUT_RESPONSE|[197]|
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
	<s:Body>
		<s:Fault>
			<faultcode xmlns:a="http://tresoap.intecbilling.com/fault/2.0">
				a:ApplicationException
			</faultcode>
			<faultstring xml:lang="en-US">
				&lt;E97007&gt; The supplied Zip+4 code of '87144' is invalid.
			</faultstring>
			<detail xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
				<trefault:Detail xmlns:trefault="http://tresoap.intecbilling.com/fault/2.0">
					<trefault:Message>
						&lt;E97007&gt; The supplied Zip+4 code of '87144' is invalid.
					</trefault:Message>
					<trefault:ErrorId>
						97007
					</trefault:ErrorId>
				</trefault:Detail>
			</detail>
		</s:Fault>
	</s:Body>
</s:Envelope>

 

I don't exactly understand what is happening here.  I have 12 account numbers to test with, but only get this error with 3 of them.

  • August 28, 2013
  • Like
  • 0
I'm trying to use a Map to select object fields.  I want to be able to select certain fields and then make queries on those fields.
I use describe to get the fields from selected objects and then put them into a map.  I want to be able to select certain fields and populate them into a correspong map.  

I am trying to use the component found here http://blogs.developerforce.com/developer-relations/2012/06/a-multiselect-picklist-visualforce-component.html but it's not working for my map.  I've tried using a normal selectList and I can display the fields (though it's ugly atm) but after selecting it doesn't populate to the correspoding map.  I've tried using a List as well and got the same results.

My visualforce page here.

<apex:page standardController="Custom_Object__c" extensions="customController">
    <apex:pageBlock >
        <apex:form >
            <apex:commandButton value="Select Objects" action="{!getObjectFields}" rerender="picklists"/>
            <apex:commandbutton value="Get Selected Fields" action="{!printOptions}" rerender="out"/>
           
        <apex:pageBlockSection > 
           
            <c:MultiselectPicklist leftLabel="Objects" leftOptions="{!SupportedObjects}" rightLabel="Objects" rightoptions="{!SelectedObjects}" size="14" width="150px"/>  <!--This works-->
           
        </apex:pageBlockSection>
        </apex:form>
    </apex:pageBlock>

    <apex:pageBlock >
        <apex:form >
        <apex:pageBlockSection  >
            <apex:outputPanel id="picklists">
           
            <apex:repeat value="{!objectFieldMap}" var="key">
                <apex:selectList value="{!selectedFieldsMap[key]}" multiselect="true"><--I can see the fields, but can't populate-->
                    <apex:selectOptions value="{!objectFieldMap[key]}"></apex:selectOptions>
                </apex:selectList>
                <!--<c:MultiselectPicklist leftLabel="Objects" leftOptions="{!objectFieldMap[key]}" rightLabel="Objects" rightoptions="{!selectedFieldsMap[key]}" size="14" width="150px"/> This doesn't work -->
            </apex:repeat>           
            </apex:outputPanel>
           
        </apex:pageBlockSection>
     </apex:form>
    </apex:pageBlock>
</apex:page>

My Controller here

public class customController{
   
    public List<selectOption> supportedObjects {get; set;}//Used for component to get objects -- this works
    public List<selectOption> SelectedObjects {get; set;}//Used for component to get objects -- this works
   
    public Map<String,SelectOption[]> objectFieldMap{get;set;}//<-- This contains all fields for an object
    public Map<String,String[]> selectedFieldsMap{get;set;}//<-- This should receive the selected fields
   
    public List<List<SelectOption>> fieldSelections{get;set;}//<-- This contains all fields for an object when I tried using a list
    public List<List<String>> selectedFields{get;set;}//<--This should receive the selected fields when I tried using a list
   
    Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe(); 
   
    public LookbookCreationController(ApexPages.StandardController stdController){
        SelectedObjects = new List<SelectOption>();
        fieldSelections= new List<List<SelectOption>>();
        init();
    }
   
    private void init(){
   
        supportedObjects = new List<selectoption>();
        Schema.DescribeFieldResult fieldResult = Custom_Object__c.Object__c.getDescribe();//Mulitselect picklist on custom object that has a list of objects to use
        for( Schema.PicklistEntry e : fieldResult.getPicklistValues() ){
            supportedObjects.add( new SelectOption( e.getLabel(), e.getValue() ) );  
        }
    }
   
    public PageReference printOptions(){
        System.debug( selectedFieldsMap );//Using this to see if the map is populated.  
        return null;
    }
   
   
    public void getObjectFields(){
       
        selectedFields = new List<List<String>>();
        objectFieldMap = new Map<String,List<SelectOption>>();
        selectedFieldsMap = new Map<String,List<String>>();

        for(SelectOption o : SelectedObjects){
           
           //Describe stuff to get all fields for the selected Objects. This part works
            List<SelectOption> options = new List<SelectOption>();
            Schema.SObjectType systemObjectType = gd.get(o.getValue());
            Schema.DescribeSObjectResult r = systemObjectType.getDescribe();
            Map<String, Schema.SObjectField> M = r.fields.getMap();
            for( Schema.SObjectField fieldAPI : M.values() ) {
                options.add(new SelectOption(fieldAPI.getDescribe().getName() , fieldAPI.getDescribe().getLabel())) ; 
            } 
            objectFieldMap.put( o.getValue(), options );
            selectedFieldsMap.put( o.getValue(), new List<String>() );
            fieldSelections.add( options );
            selectedFields.add( new List<String>() );
        }
    }


When I use the Map or List, things display but selecting doesn't populate.  Using the component I get the following error Cannot convert the value of '{!leftOptions}' to the expected type. After selecting the objects and trying to display the component.
  • January 23, 2014
  • Like
  • 1

I'm trying to send an email that includes a link to a record in Saleforce using apex email alert and the setHtmlBody method.  I'm trying to send the link like so..

 

<a href="'+URL.getSalesforceBaseUrl()+'/'+workOrder.id+'">'+workOrder.Name+'</a>

 The email gets sent out just fine, but the link isn't there.  When I look at the source in the email it shows the a tag without the href attribute like so...

<a>Work Order Name</a>

 Can anybody tell me why this is happening and what I can do to get the link to work?

  • December 04, 2013
  • Like
  • 0

I am looking to have my trigger used based on the record type of the custom object.  So only use the trigger if recordtype = daily visit.  Here is the trigger i am using.  Any suggestions on how this could work

 

 trigger SV_Cases on SiteVisit__c (before insert) {
 List<Case>cases=new List<Case>();
    
    for(sitevisit__C b:Trigger.new)
        {
             
     if(b.baseboard_stairway__c == 'False')
    {
    Case newCase=new Case(subject='Test',Status='New',Origin='Web');
    insert newCase; 
}
}

}

I am trying to call the webservice and getting the following error:

 

System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: <E97007> The supplied Zip+4 code of '87144' is invalid. faultcode=a:ApplicationException faultactor=

 

I get this error from a class generated from a WSDL in a sandbox org but using a dev org with the same WSDL I get a little more detailed info. 

06:50:06.284 (284395000)|CALLOUT_REQUEST|[197]|
<?xml version="1.0" encoding="UTF-8"?>
	<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
		<env:Header />
		<env:Body>
			<GetAccountDetailsByAccountNumber xmlns="http://tempuri.org/">
				<AccountDetails>
					<AccountNumber xmlns="http://schemas.datacontract.org/2004/07/xxx.xxx.SFDC.Contracts">
						010655421
					</AccountNumber>
				</AccountDetails>
			</GetAccountDetailsByAccountNumber>		
		</env:Body>
	</env:Envelope>

06:50:06.284 (284490000)|CALLOUT_REQUEST|[197]|
GetAccountDetailsByAccountNumber_element:[AccountDetails=GetAccountDetailsByAccountNumberRequest:[AccountNumber=010655421, AccountNumber_type_info=(AccountNumber, http://www.w3.org/2001/XMLSchema, string, 1, 1, true), apex_schema_type_info=(http://schemas.datacontract.org/2004/07/xxx.xxx.SFDC.Contracts, true, false), field_order_type_info=(AccountNumber)], AccountDetails_type_info=(AccountDetails, http://schemas.datacontract.org/2004/07/xxx.xxx.SFDC.Contracts, GetAccountDetailsByAccountNumberRequest, 0, 1, true), apex_schema_type_info=(http://tempuri.org/, true, false), field_order_type_info=(AccountDetails)]::SFDC_STACK_DEPTH=1 SOAPAction="http://tempuri.org/IAccountDetails/GetAccountDetailsByAccountNumber" User-Agent=SFDC-Callout/28.0 Accept=text/xml Content-Type=text/xml; charset=UTF-8 

06:50:07.626 (1626529000)|CALLOUT_RESPONSE|[197]|
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
	<s:Body>
		<s:Fault>
			<faultcode xmlns:a="http://tresoap.intecbilling.com/fault/2.0">
				a:ApplicationException
			</faultcode>
			<faultstring xml:lang="en-US">
				&lt;E97007&gt; The supplied Zip+4 code of '87144' is invalid.
			</faultstring>
			<detail xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
				<trefault:Detail xmlns:trefault="http://tresoap.intecbilling.com/fault/2.0">
					<trefault:Message>
						&lt;E97007&gt; The supplied Zip+4 code of '87144' is invalid.
					</trefault:Message>
					<trefault:ErrorId>
						97007
					</trefault:ErrorId>
				</trefault:Detail>
			</detail>
		</s:Fault>
	</s:Body>
</s:Envelope>

 

I don't exactly understand what is happening here.  I have 12 account numbers to test with, but only get this error with 3 of them.

  • August 28, 2013
  • Like
  • 0

Hi All,

 

I did start with this thread: http://boards.developerforce.com/t5/General-Development/Install-Eclipse-Juno-4-2-with-Force-com-IDE/m-p/462323/highlight/true#M72103

 

But I am still running into the same problem. Here's my setup: 

 

Here's my setup

- Running Eclipse 4.2 as Admin (downloaded from here: http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/junor) and installed to desktop.

- JAVA_HOME set to C:\Program Files\Java\jdk1.7.0_05 (upgraded from jdk1.6.0_23) downloaded from http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1637583.html

- Tried installing the Force.com IDE from the Eclipse Marketplace and got this error:

 

Cannot complete the install because one or more required items could not be found.
  Software being installed: Force.com IDE 25.0.0.201206181021 (com.salesforce.ide.feature.feature.group 25.0.0.201206181021)
  Missing requirement: Force.com IDE 25.0.0.201206181021 (com.salesforce.ide.feature.feature.group 25.0.0.201206181021) requires 'org.eclipse.update.ui 0.0.0' but it could not be found

 

Have I installed something incorrectly or overlooked something?

This is actually a confirmation to SFDC (so if some God in the SFDC heaven or any other wild heaven is watching me, please answer to my question...)

I got an parse error when I tried to generate apex class from WSDL by WSDL2APEX.

 

Error: Unable to find schema for element; {http://www.w3.org/2001/XMLSchema}string

like this post: http://community.salesforce.com/sforce/board/message?board.id=general_development&message.id=28929

Long story in short, I found the reason. Request/Response message doesn't accept just a xsd:string. It has to be complexType.

This post

http://community.salesforce.com/sforce/board/message?board.id=apex&message.id=2058

mentioned that SFDC doesn't support simpleType restriction, but I wonder it also mens it doesn't support single-standard type Request/Response.

 

Question: Am I correct? which means there is no way to use this WSDL? (this WSDL is from a product, so I can't change the actual format... only way to use this is to create a custom HTTP request...)

 

So, this doesn't work, because SessionID is xsd:string.

<definitions xmlns:tns="http://www.hoge.com/hoge/Object"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
name="Companies"
targetNamespace="http://www.hoge.com/hoge/Object">
<types>
<xsd:schema elementFormDefault="qualified" targetNamespace="http://www.hoge.com/hoge/Object">
<xsd:element name="Login">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="1" name="Username" type="xsd:string"/>
<xsd:element minOccurs="0" name="Password" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="SessionID" type="xsd:string"/>
</xsd:schema>
</types>
<message name="Login">
<part element="tns:Login" name="parameters"/>
</message>
<message name="LoginResponse">
<part element="tns:SessionID" name="body"/>
</message>

<portType name="CompaniesPort">
<operation name="Login">
<input message="tns:Login"/>
<output message="tns:LoginResponse"/>
</operation>
</portType>
<binding name="CompaniesSoapBinding" type="tns:CompaniesPort">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="Login">
<soap:operation soapAction="https://morethan/foo/bar/Login" style="document"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="CompaniesService">
<port binding="tns:CompaniesSoapBinding" name="CompaniesService">
<soap:address location="https://morethan/foo/bar"/>
</port>
</service>
</definitions>

 This works because LoginOut is complexType.

<definitions xmlns:tns="http://www.hoge.com/hoge/Object"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
name="Companies"
targetNamespace="http://www.hoge.com/hoge/Object">
<types>
<xsd:schema elementFormDefault="qualified" targetNamespace="http://www.hoge.com/hoge/Object">
<xsd:element name="Login">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="1" name="Username" type="xsd:string"/>
<xsd:element minOccurs="0" name="Password" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="LoginOut">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="SessionID" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>

</xsd:schema>
</types>
<message name="Login">
<part element="tns:Login" name="parameters"/>
</message>
<message name="LoginResponse">
<part element="tns:LoginOut" name="body"/>
</message>
<portType name="CompaniesPort">
<operation name="Login">
<input message="tns:Login"/>
<output message="tns:LoginResponse"/>
</operation>
</portType>
<binding name="CompaniesSoapBinding" type="tns:CompaniesPort">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="Login">
<soap:operation soapAction="https://morethan/foo/bar/Login" style="document"/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<service name="CompaniesService">
<port binding="tns:CompaniesSoapBinding" name="CompaniesService">
<soap:address location="https://morethan/foo/bar"/>
</port>
</service>
</definitions>
ThomasTT