An effort to bring a revolution in Salesforce.

Tuesday, 21 July 2015

How to Create field set in Salesforce...

Apex Code


 String queryFields = null;
             for(Schema.FieldSetMember field : SObjectType.Task.FieldSets.Activity_Detail_Page.getFields()){
                queryFields = (queryFields == null ? field.getFieldPath() : queryFields+', '+field.getFieldPath());
             }
             String query = 'Select '+queryFields+',Description from Task where Id=\''+activityId+'\'';
             task = Database.query(query);




Page Code.


  <apex:pageBlock id="Block1">
          <apex:pageBlockSection title="Activity Detail" collapsible="False">
            <apex:repeat value="{!$ObjectType.Task.FieldSets.Activity_Detail_Page}" var="field">
                <apex:outputField value="{!Task[field.fieldPath]}" />
            </apex:repeat>
          </apex:pageBlockSection>
          <apex:pageBlockSection columns="1">
                <apex:outputfield value="{!task.Description}">
                </apex:outputfield>
            </apex:pageBlockSection>

    </apex:pageBlock>

No comments:

Post a Comment

Get Gmail, Docs, Drive, and Calendar for business