Skip to main content
copied comments to post
Source Link
crmprogdev
  • 41k
  • 9
  • 58
  • 116

Field column is nothing but fields on case. email Address is of type text so value should be of input type text. If I am selecting Status field which is Picklist on Case, then on Value column next to Status I want it as Picklist values of status.I should be able to select a picklist

Field column is nothing but fields on case. email Address is of type text so value should be of input type text. If I am selecting Status field which is Picklist on Case, then on Value column next to Status I want it as Picklist values of status.I should be able to select a picklist

 <apex:pageBlockSection title="Rule Criteria">
    <apex:pageBlockTable value="{!wrappers}" var="wrapper" id="wtable">
        <apex:column headerValue="Ident">
            <apex:outputText value="{!wrapper.ident}"/>
        </apex:column>
        <apex:column headerValue="Field">
            <apex:selectList value="{!wrapper.acc.WFCField__c}" size="1">
            <apex:selectOptions value="{!FieldSeletOptions}"/>
            </apex:selectList>
        </apex:column>
        <apex:column headerValue="Operator">
            <apex:inputField value="{!wrapper.acc.WFC_Operator__c}"/>
        </apex:column>
        <apex:column headerValue="Value">
            <apex:inputField value="{!wrapper.acc.WFCField__c}"/>
        </apex:column>
        <!-- 
        <apex:column headerValue="Action">
            <apex:commandButton value="Delete" action="{!delWrapper}" 
                rerender="wtable">
                <apex:param name="toDelIdent" value="{!wrapper.ident}" 
                    assignTo="{!toDelIdent}"/>
            </apex:commandButton>
        </apex:column>
        -->
    </apex:pageBlockTable>
   </apex:pageBlockSection>
public  List<SelectOption> getFieldSeletOptions()
   {
       List<SelectOption> fieldOptions = new List<SelectOption>();
        String type='Case'; 

    Map<String, Schema.SObjectType> schemaMap = 
        Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
        Schema.SObjectType caseSchema = schemaMap.get(type);
        Map<String, Schema.SObjectField> fieldMap = 
        caseSchema.getDescribe().fields.getMap();
         SelectOption optionNone = new SelectOption('', '--None--');
         fieldOptions.add(optionNone);
        
        for (String fieldName: fieldMap.keySet()) {
        
        System.debug('##Field API Name='+fieldName);// list of all field API name
        //It provides to get the object fields label.
        Schema.DisplayType fieldType = 
            fieldMap.get(fieldName).getDescribe().getType();
        if(fieldType != Schema.DisplayType.ID)
        {
            SelectOption option = new SelectOption(fieldName, 
                fieldMap.get(fieldName).getDescribe().getLabel());
            fieldOptions.add(option);
        }
        }
        return fieldOptions;
    }
   
public class WFCriteriaWrapper
  {
     public WFCriteria__c acc { get; private set; }
     public Integer ident { get; private set; }
      
     public WFCriteriaWrapper(Integer inIdent)
     {
        ident=inIdent;
        acc=new WFCriteria__c();
     }
  }
  
 <apex:pageBlockSection title="Rule Criteria">
 <apex:pageBlockTable value="{!wrappers}" var="wrapper" id="wtable">
    <apex:column headerValue="Ident">
       <apex:outputText value="{!wrapper.ident}"/>
    </apex:column>
    <apex:column headerValue="Field">
       <apex:selectList value="{!wrapper.acc.WFCField__c}" size="1">
       <apex:selectOptions value="{!FieldSeletOptions}"/>
       </apex:selectList>
    </apex:column>
    <apex:column headerValue="Operator">
       <apex:inputField value="{!wrapper.acc.WFC_Operator__c}"/>
    </apex:column>
    <apex:column headerValue="Value">
       <apex:inputField value="{!wrapper.acc.WFCField__c}"/>
    </apex:column>
   <!-- <apex:column headerValue="Action">
       <apex:commandButton value="Delete" action="{!delWrapper}" rerender="wtable">
          <apex:param name="toDelIdent" value="{!wrapper.ident}" assignTo="{!toDelIdent}"/>
       </apex:commandButton>
    </apex:column>-->
 </apex:pageBlockTable>
   </apex:pageBlockSection>
public  List<SelectOption> getFieldSeletOptions()
   {
       List<SelectOption> fieldOptions = new List<SelectOption>();
        String type='Case';
        
        Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
        Schema.SObjectType caseSchema = schemaMap.get(type);
        Map<String, Schema.SObjectField> fieldMap = caseSchema.getDescribe().fields.getMap();
         SelectOption optionNone = new SelectOption('', '--None--');
         fieldOptions.add(optionNone);
        
        for (String fieldName: fieldMap.keySet()) {
        
        System.debug('##Field API Name='+fieldName);// list of all field API name
       //It provides to get the object fields label.
        Schema.DisplayType fieldType = fieldMap.get(fieldName).getDescribe().getType();
        if(fieldType != Schema.DisplayType.ID)
        {
            SelectOption option = new SelectOption(fieldName, fieldMap.get(fieldName).getDescribe().getLabel());
            fieldOptions.add(option);
        }
        }
        return fieldOptions;
    }
   
public class WFCriteriaWrapper
  {
     public WFCriteria__c acc {get; private set;}
     public Integer ident {get; private set;}
      
     public WFCriteriaWrapper(Integer inIdent)
     {
        ident=inIdent;
        acc=new WFCriteria__c();
     }
  }
  
<apex:pageBlockSection title="Rule Criteria">
    <apex:pageBlockTable value="{!wrappers}" var="wrapper" id="wtable">
        <apex:column headerValue="Ident">
            <apex:outputText value="{!wrapper.ident}"/>
        </apex:column>
        <apex:column headerValue="Field">
            <apex:selectList value="{!wrapper.acc.WFCField__c}" size="1">
            <apex:selectOptions value="{!FieldSeletOptions}"/>
            </apex:selectList>
        </apex:column>
        <apex:column headerValue="Operator">
            <apex:inputField value="{!wrapper.acc.WFC_Operator__c}"/>
        </apex:column>
        <apex:column headerValue="Value">
            <apex:inputField value="{!wrapper.acc.WFCField__c}"/>
        </apex:column>
        <!-- 
        <apex:column headerValue="Action">
            <apex:commandButton value="Delete" action="{!delWrapper}" 
                rerender="wtable">
                <apex:param name="toDelIdent" value="{!wrapper.ident}" 
                    assignTo="{!toDelIdent}"/>
            </apex:commandButton>
        </apex:column>
        -->
    </apex:pageBlockTable>
</apex:pageBlockSection>
public List<SelectOption> getFieldSeletOptions() {
    List<SelectOption> fieldOptions = new List<SelectOption>();
    String type='Case'; 

    Map<String, Schema.SObjectType> schemaMap = 
        Schema.getGlobalDescribe();
    Schema.SObjectType caseSchema = schemaMap.get(type);
    Map<String, Schema.SObjectField> fieldMap = 
        caseSchema.getDescribe().fields.getMap();
    SelectOption optionNone = new SelectOption('', '--None--');
    fieldOptions.add(optionNone);

    for (String fieldName: fieldMap.keySet()) {

        System.debug('##Field API Name='+fieldName);// list of all field API name
        //It provides to get the object fields label.
        Schema.DisplayType fieldType = 
            fieldMap.get(fieldName).getDescribe().getType();
        if(fieldType != Schema.DisplayType.ID) {
            SelectOption option = new SelectOption(fieldName, 
                fieldMap.get(fieldName).getDescribe().getLabel());
            fieldOptions.add(option);
        }
    }
    return fieldOptions;
}
   
public class WFCriteriaWrapper {
    public WFCriteria__c acc { get; private set; }
    public Integer ident { get; private set; }

    public WFCriteriaWrapper(Integer inIdent) {
        ident=inIdent;
        acc=new WFCriteria__c();
    }
}
  
added 2720 characters in body
Source Link
amitghadage
  • 1.4k
  • 1
  • 9
  • 16

i.e if I am selecting field status Value should show picklists available in status field as picklist  

Visualforce :

 <apex:pageBlockSection title="Rule Criteria">
 <apex:pageBlockTable value="{!wrappers}" var="wrapper" id="wtable">
    <apex:column headerValue="Ident">
       <apex:outputText value="{!wrapper.ident}"/>
    </apex:column>
    <apex:column headerValue="Field">
       <apex:selectList value="{!wrapper.acc.WFCField__c}" size="1">
       <apex:selectOptions value="{!FieldSeletOptions}"/>
       </apex:selectList>
    </apex:column>
    <apex:column headerValue="Operator">
       <apex:inputField value="{!wrapper.acc.WFC_Operator__c}"/>
    </apex:column>
    <apex:column headerValue="Value">
       <apex:inputField value="{!wrapper.acc.WFCField__c}"/>
    </apex:column>
   <!-- <apex:column headerValue="Action">
       <apex:commandButton value="Delete" action="{!delWrapper}" rerender="wtable">
          <apex:param name="toDelIdent" value="{!wrapper.ident}" assignTo="{!toDelIdent}"/>
       </apex:commandButton>
    </apex:column>-->
 </apex:pageBlockTable>
   </apex:pageBlockSection>

Code in controller get SelectOpions for field column:

public  List<SelectOption> getFieldSeletOptions()
   {
       List<SelectOption> fieldOptions = new List<SelectOption>();
        String type='Case';
        
        Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
        Schema.SObjectType caseSchema = schemaMap.get(type);
        Map<String, Schema.SObjectField> fieldMap = caseSchema.getDescribe().fields.getMap();
         SelectOption optionNone = new SelectOption('', '--None--');
         fieldOptions.add(optionNone);
        
        for (String fieldName: fieldMap.keySet()) {
        
        System.debug('##Field API Name='+fieldName);// list of all field API name
       //It provides to get the object fields label.
        Schema.DisplayType fieldType = fieldMap.get(fieldName).getDescribe().getType();
        if(fieldType != Schema.DisplayType.ID)
        {
            SelectOption option = new SelectOption(fieldName, fieldMap.get(fieldName).getDescribe().getLabel());
            fieldOptions.add(option);
        }
        }
        return fieldOptions;
    }
   

Wrapper

public class WFCriteriaWrapper
  {
     public WFCriteria__c acc {get; private set;}
     public Integer ident {get; private set;}
      
     public WFCriteriaWrapper(Integer inIdent)
     {
        ident=inIdent;
        acc=new WFCriteria__c();
     }
  }
  

enter image description here

i.e if I am selecting field status Value should show picklists available in status field as picklist  enter image description here

i.e if I am selecting field status Value should show picklists available in status field as picklist

Visualforce :

 <apex:pageBlockSection title="Rule Criteria">
 <apex:pageBlockTable value="{!wrappers}" var="wrapper" id="wtable">
    <apex:column headerValue="Ident">
       <apex:outputText value="{!wrapper.ident}"/>
    </apex:column>
    <apex:column headerValue="Field">
       <apex:selectList value="{!wrapper.acc.WFCField__c}" size="1">
       <apex:selectOptions value="{!FieldSeletOptions}"/>
       </apex:selectList>
    </apex:column>
    <apex:column headerValue="Operator">
       <apex:inputField value="{!wrapper.acc.WFC_Operator__c}"/>
    </apex:column>
    <apex:column headerValue="Value">
       <apex:inputField value="{!wrapper.acc.WFCField__c}"/>
    </apex:column>
   <!-- <apex:column headerValue="Action">
       <apex:commandButton value="Delete" action="{!delWrapper}" rerender="wtable">
          <apex:param name="toDelIdent" value="{!wrapper.ident}" assignTo="{!toDelIdent}"/>
       </apex:commandButton>
    </apex:column>-->
 </apex:pageBlockTable>
   </apex:pageBlockSection>

Code in controller get SelectOpions for field column:

public  List<SelectOption> getFieldSeletOptions()
   {
       List<SelectOption> fieldOptions = new List<SelectOption>();
        String type='Case';
        
        Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
        Schema.SObjectType caseSchema = schemaMap.get(type);
        Map<String, Schema.SObjectField> fieldMap = caseSchema.getDescribe().fields.getMap();
         SelectOption optionNone = new SelectOption('', '--None--');
         fieldOptions.add(optionNone);
        
        for (String fieldName: fieldMap.keySet()) {
        
        System.debug('##Field API Name='+fieldName);// list of all field API name
       //It provides to get the object fields label.
        Schema.DisplayType fieldType = fieldMap.get(fieldName).getDescribe().getType();
        if(fieldType != Schema.DisplayType.ID)
        {
            SelectOption option = new SelectOption(fieldName, fieldMap.get(fieldName).getDescribe().getLabel());
            fieldOptions.add(option);
        }
        }
        return fieldOptions;
    }
   

Wrapper

public class WFCriteriaWrapper
  {
     public WFCriteria__c acc {get; private set;}
     public Integer ident {get; private set;}
      
     public WFCriteriaWrapper(Integer inIdent)
     {
        ident=inIdent;
        acc=new WFCriteria__c();
     }
  }
  

enter image description here

Source Link
amitghadage
  • 1.4k
  • 1
  • 9
  • 16
Loading