how to display a table with dynamic columns in vf page

how to display a table with dynamic columns in vf page

<apex:pageBlock id="block">
    <apex:pageBlockTable id="table" var="exhlst" value="{!exhibitorList}">
    <tr>
        <td styleClass="freeze_horizontal">
        
        <b><apex:outputField value="{!exhlst.Name}" styleClass="freeze_horizontal"/></b>
        
        </td>
        <td>
            <apex:repeat value="{!$ObjectType.Exhibitor_Authenticity__c.FieldSets.NationalitiesName}" var="c">
              <apex:column headerValue="{!$ObjectType.Exhibitor_Authenticity__c.fields[c].Label}">
              <div style="background-color:{!If(exhlst[c]== 'Authentic','#b3ffb3',If(exhlst[c]== 'Remaining','#ffd480','#ff9999'))};">    
                    <apex:outputField value="{!exhlst[c]}"></apex:outputField>
               </div>
            </apex:column>
            </apex:repeat>
        </td>
    </tr>
   </apex:pageBlockTable>
</apex:pageBlock>

Apex Fieldset - getfieldpath in salesforce

use get method to iterate the fieldset value.

public static List<Schema.FieldSetMember> getFields(){
return SObjectType.Account.FieldSets.ExhibitorAuthenticity.getFields();
}

 for(Account itr:exhibitorAuthList){
                for(Schema.FieldSetMember f : getFields()){
                    if(itr.get(f.getFieldPath())=='Apple'){
                        exhibitorAuth.add('Apple');
                    }else if(itr.get(f.getFieldPath())=='Banana'){
                        exhibitorRemaining.add('Banana');
                    } 
                }
            }

    system.debug('API Name ====>' + fieldSetMemberObj.getFieldPath()); //api name
    system.debug('Label ====>' + fieldSetMemberObj.getLabel());
    system.debug('Required ====>' + fieldSetMemberObj.getRequired());
    system.debug('DbRequired ====>' + fieldSetMemberObj.getDbRequired());
    system.debug('Type ====>' + fieldSetMemberObj.getType());

Apex Map with comma separate value

Apex Iterate the map value and separate with comma

if(Trigger.isUpdate && Trigger.isAfter){
        Map<string,string> caseshopID = new Map<string,string>(); 
        for(case itr:trigger.new){
            if(itr.Case_Record_Type__c=='Additional Visa/GVAC' && itr.AdditionalQuotaRequest__c){
                caseshopID.put(itr.id,itr.Shop__c+','+itr.Additional_Quota__c);
            }
        }
        if(caseshopID.size()>0){
            caseglobalHelperClass.updateShopQuota(caseshopID);
        }
    }


public static void updateShopQuota(Map<string,string> caseshopid){

        set<string> shopID = new set<string>();
        Map<string,string> mapQuotaNum = new Map<string,string>();
        for(string a:caseshopid.values()){
            List<string> b=a.split(',');
            string c = string.join(b,',');
            List<String> d= c.split(',');
            system.debug('-------'+d[0]+'-----'+d[1]);
            shopID.add(d[0]);
            mapQuotaNum.put(d[0],d[1]);
        }
     
        List<Shop__c> updateshpList = [select id,IncreasedQuota__c from Shop__c where id IN:shopID];
        for(Shop__c itr:updateshpList){
           itr.IncreasedQuota__c  = Integer.valueof(mapQuotaNum.get(itr.Id));
        }
     
        if(updateshpList.size()>0){
            update updateshpList;
        }
    }

FieldSet in Apex

FieldSet in Apex


List<Schema.FieldSetMember> fieldSetMemberList =  Util.readFieldSetMethod('Case_FieldSet','Case');
for(Schema.FieldSetMember fieldSetMemberObj : fieldSetMemberList){
    system.debug('API Name ====>' + fieldSetMemberObj.getFieldPath()); //api name
    system.debug('Label ====>' + fieldSetMemberObj.getLabel());
    system.debug('Required ====>' + fieldSetMemberObj.getRequired());
    system.debug('DbRequired ====>' + fieldSetMemberObj.getDbRequired());
    system.debug('Type ====>' + fieldSetMemberObj.getType());   //type - STRING,PICKLIST
}

public static List<Schema.FieldSetMember> readFieldSetMethod(String fieldSetName, String ObjectName){
    Map<String, Schema.SObjectType> GlobalDescribeMap = Schema.getGlobalDescribe();
    Schema.SObjectType SObjectTypeObj = GlobalDescribeMap.get(ObjectName);
    Schema.DescribeSObjectResult DescribeSObjectResultObj = SObjectTypeObj.getDescribe();

    //system.debug('====>' + DescribeSObjectResultObj.FieldSets.getMap().get(fieldSetName));

    Schema.FieldSet fieldSetObj = DescribeSObjectResultObj.FieldSets.getMap().get(fieldSetName);

    //List<Schema.FieldSetMember> fieldSetMemberList =  fieldSetObj.getFields();
    //system.debug('fieldSetMemberList ====>' + fieldSetMemberList); 
    return fieldSetObj.getFields();
}  

@Test Visible Example

@Test Visible - Example

public class TestVisibleExample {
    // Private member variable
    @TestVisible private static Integer recordNumber = 1;

    // Private method
    @TestVisible private static void updateRecord(String name) {
        // Do something
    }
}


@isTest
private class TestVisibleExampleTest {
    @isTest static void test1() {
        // Access private variable annotated with TestVisible
        Integer i = TestVisibleExample.recordNumber;
        System.assertEquals(1, i);

        // Access private method annotated with TestVisible
        TestVisibleExample.updateRecord('RecordName');
        // Perform some verification
    }
}

SOQL on Salesforce Approval Process

ProcessInstance

SELECT Id, (SELECT Id, ProcessInstanceId, StepStatus, Comments, CreatedDate FROM Steps ORDER BY CreatedDate DESC)TargetObjectId, Status FROM ProcessInstance WHERE TargetObjectId='5009E000007vqVS'

ProcessInstanceStep

SELECT ActorId, Comments, CreatedById, CreatedDate, ElapsedTimeInDays, ElapsedTimeInHours, ElapsedTimeInMinutes, Id, OriginalActorId, ProcessInstanceId, StepNodeId, StepStatus, SystemModstamp FROM ProcessInstanceStep where ProcessInstanceId='04g9E000000P7ysQAC'


ProcessInstance with Step Name

SELECT Id, Name, ProcessDefinitionId FROM ProcessNode WHERE ProcessDefinitionId IN (SELECT ProcessDefinitionID FROM ProcessInstance WHERE TargetObjectId = '5009E000007vqTH')


Visualforce Bar Charts and Pie Chart

Visualforce Bar Charts and Pie Chart.

please find the more information on:

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_charting_appearance_bar_charts.htm

Visualforce page code:

<apex:page standardController="Account" extensions="ShowAccountPieChart">
    <apex:chart height="250" width="350" data="{!pieData}">
        <apex:pieSeries dataField="data" labelField="name"/>
        <apex:legend position="right"/>
    </apex:chart>
     <apex:outputPanel>
        <apex:pageblock title="Business Category Total Allowance" >
        <apex:chart height="250" width="600" data="{!pieData}">
            <apex:axis type="Numeric" position="left" fields="data" title="Allowed Visa"/> 
            <apex:axis type="Category" position="bottom" fields="name" title="Utilized Visa"/>         
            <apex:barSeries orientation="vertical" axis="left" xField="name" yField="data"/>
        </apex:chart>
    </apex:pageblock> 
    </apex:outputPanel>
</apex:page>

Apex controller:

public class ShowAccountPieChart{
 
    public ShowAccountPieChart(ApexPages.StandardController controller){
    //
    }
    public List<PieWedgeData> getPieData() {
        List<PieWedgeData> data = new List<PieWedgeData>();
        List<Account> memb = new List<Account>();
     
        //string accId = ApexPages.currentPage().getParameters().get('pv0');
        string accId = 'xxxx';
        string sql = 'SELECT Name,AllowedExhbitorsRollUp__c,Number_of_Visas_Utilised__c,Number_of_Cleaners_Utilised__c,Number_of_Maintenance_Staff_Utilised__c,IdCardRollUp__c,twpRollUp__c,FestivalVisaRollUp__c FROM Account where ID =:accId';
        memb = Database.Query(sql);
        for(Account a:memb){
            //data.add(new PieWedgeData('Allowance',Integer.valueof(a.AllowedExhbitorsRollUp__c)));
            data.add(new PieWedgeData('Visa Utilised',Integer.valueof(a.AllowedExhbitorsRollUp__c)/Integer.valueof(a.Number_of_Visas_Utilised__c)*10));
            data.add(new PieWedgeData('Cleaners Utilised',Integer.valueof(a.AllowedExhbitorsRollUp__c)/Integer.valueof(a.Number_of_Cleaners_Utilised__c)*10));
            data.add(new PieWedgeData('Maintenance Staff',Integer.valueof(a.AllowedExhbitorsRollUp__c)/Integer.valueof(a.Number_of_Maintenance_Staff_Utilised__c)*10));
            data.add(new PieWedgeData('GVAC',Integer.valueof(a.AllowedExhbitorsRollUp__c)/Integer.valueof(a.IdCardRollUp__c)*10));
            data.add(new PieWedgeData('Roll up',Integer.valueof(a.AllowedExhbitorsRollUp__c)/Integer.valueof(a.twpRollUp__c)*10));
            data.add(new PieWedgeData('Festival visa',Integer.valueof(a.AllowedExhbitorsRollUp__c)/Integer.valueof(a.FestivalVisaRollUp__c)*10));
        }
        /*
        data.add(new PieWedgeData('Jan', 30));
        data.add(new PieWedgeData('Jan', 30));
        data.add(new PieWedgeData('Feb', 15));
        data.add(new PieWedgeData('Mar', 10));
        data.add(new PieWedgeData('Apr', 20));
        data.add(new PieWedgeData('May', 20));
        data.add(new PieWedgeData('Jun', 5));
        */
        return data;
    }

    // Wrapper class
    public class PieWedgeData {

        public String name { get; set; }
        public Integer data { get; set; }

        public PieWedgeData(String name, Integer data) {
            this.name = name;
            this.data = data;
        }
    }
}


Javascript to validate minimum legth

Javascript to validate minimum legth

The below code will allow only two character

onkeypress="this.value= this.value.replace(/[^0-9]/g, '');return limitKeypress(event,this.value,2)"

function limitKeypress(event, value, maxLength) {
    if (value != undefined && value.toString().length >= maxLength) {
        event.preventDefault();
    }
}

Pass Variable from Apex controller to Javascript

Pass Variable from Apex controller to Javascript


1.Define the Javascript
           var serviceFeesDict = {};
           
 2.use ready fucntion to load the variable when page get loaded.         
            $(document).ready(function() {
           
                    <apex:repeat value="{!serviceFeesList}" var="serviceFee">
                        serviceFeesDict['{!serviceFee.Name}'] = {!serviceFee.Fee__c};
                    </apex:repeat>
              } 
3.use the Apex repeat var to iterate the value in JS.

               var feesValue = 0;
                if(isAA){
                    feesValue += serviceFeesDict['AA'];
                }
                if (isBB){
                    feesValue += serviceFeesDict['BB'];
                }

Salesforce AppExchange products

Salesforce AppExchange products

1. Document Creation and Automation: DrawLoop vs. Conga Merge--DrawLoop (willing to do custom work for free and had a more friendly administrative UI).

2. e-Signature: DocuSign vs. EchoSign--DocuSign (supported and was willing to help us with our non-SF API contracts and configuration; best contract app for any real estate industries; supports the red-line process). EchoSign was very arrogant and unhelpful when it came to special requests. They also tried to make you feel stupid for selecting another vendor. Plus, functionality (API integrations and red-line process was not supported).

3. Marketing Automation: Genius vs. Marketo--Genius (more friendly UI; all data stays in SFDC--one database; better price point; better customer support; supposed to release an open API in July/August of 2011). Marketo was a tad more complex to configure and the data was pushed and pulled from 2 databases.

4. Lead Generation: Jigsaw vs. NetProspex vs. InsideView vs. Hoovers--Jigsaw (no brainer! Jigsaw was bought by SF and they reconcile the Jigsaw contact database against all of the SFDC customers that buy it and opt for the shared licensing methodology--well, now it has been rolled into data.com). We ran accuracy tests against the other vendors, and they all had a 27% or less accuracy rate.

5. Cleansing/de-duping/normalizing data: CRM Fusion/DemandTools 2.0 vs. RingLead--CRM Fusion no contest! This is by far my favorite and most leveraged installed app. This makes mass updates, exports, new record inserts, mass record deletions, data querying a breeze. They don't use a push/pull/import/export model; the application pulls the data straight out of SFDC. There is an awesome feature that is in beta testing right now--instead of exporting the grid data, manipulating it in Excel, and uploading the new file into Mass Effect to upsert/update the data, they are putting all the functionality of an Excel spreadsheet into the application; so, you can manipulate the data (copy/paste, change values) inside the DemandTools application and click update and it pushes all of the changes straight into SFDC. I'm super stoked for this release!

6. Dialer: PowerDialer vs. Interactive Intelligence vs. Refractive Dialer--PowerDialer by InsideVieew (not a predictive dialer so there is no dead air, reps can generate their own call lists, context/content for the list (doesn't have to be sales based), record multiple VM's and select which VM they want to leave, real-time call dispositioning and activity logging, and perform actions when the call connects with the customer--send emails, content, etc.).

Visualforce page Model box onmouse over or onclick

Visualforce page Model box onmouse over or onclick


<a target="_self" href="/XXX/servlet/servlet.FileDownload?file={!caseAttachment.Attachment_Id__c}" download="{!caseAttachment.attachment_File_Name__c}" onmouseover="showDialog(this,'some message');"> <i class="fa fa-eye" style="float: left;margin-left: 30px;color: #61c027;font-size:24px;" ></i> </a>

<script>
//If you are using string literals, be sure to escape your double quotes!
function showDialog(urlval, message, width, largerText) {
    //set up the vars
var urlval = urlval;
//alert(urlval);
    var dialogTitle = 'Attachment',
        //dialogHTML = message,
dialogHTML = '<iframe src="'+urlval+'" width="420" height="315" frameborder="0" allowfullscreen></iframe>',
        dialogWidth,
        modalBlocker = document.createElement("div"),
        modalBox = document.createElement("div"),
        modalBoxInner = document.createElement("div"),
        modalBoxTitle = document.createElement("h3"),
        modalBoxClose = document.createElement("span");

    if (width) {
        dialogWidth = width;
    }
    else {
        dialogWidth = '500';
    }

    //debug info
    //console.log('title', title);
    //console.log('message', message);
    //console.log('width', width);
    //console.log('largerText', largerText);

 

    //Get the document size
    var w = 0; var h = 0;
    if (!window.innerWidth) {
        if (!(document.documentElement.clientWidth == 0)) {
            w = document.documentElement.clientWidth;
            h = document.documentElement.clientHeight;
        } else {
            w = document.body.clientWidth;
            h = document.body.clientHeight;
        }
    } else {
        w = window.innerWidth;
        h = window.innerHeight;
    }

    //Set up the modal blocker
    modalBlocker.setAttribute('Id', '__modalBlocker');
    modalBlocker.style.width = w + 'px';
    modalBlocker.style.height = document.body.scrollHeight + 'px';
    modalBlocker.style.position = 'absolute';
    modalBlocker.style.zIndex = '20000';
    modalBlocker.style.opacity = '.5';
    modalBlocker.style.filter = 'alpha(opacity=50)';
    modalBlocker.style.backgroundColor = '#000';
    modalBlocker.style.top = 0;
    modalBlocker.style.left = 0;

    //set up the modal box...
    modalBox.setAttribute('id', '__modalBox');
    modalBox.style.backgroundColor = '#fff';
    modalBox.style.width = dialogWidth + 'px';
    modalBox.style.zIndex = '20001';
    modalBox.style.position = 'fixed';
    modalBox.style.top = '200px';
    modalBox.style.left = ((w / 2) - (dialogWidth / 2)) + 'px';
    modalBox.style.borderRadius = '4px';
    modalBox.style.boxShadow = '1px 1px 10px #000';

    //...and the inner div
    modalBoxInner.style.position = 'relative';
    modalBoxInner.style.padding = '20px';
    if (largerText) modalBoxInner.style.fontSize = '1.6em';
    modalBoxInner.innerHTML = dialogHTML;


    //set up the close button
    modalBoxClose.innerHTML = 'X';
    modalBoxClose.title = 'Close';
    modalBoxClose.style.fontSize = '12px';
    modalBoxClose.style.backgroundColor = 'rgb(224, 7, 7)';
    modalBoxClose.style.color = '#fff';
    modalBoxClose.style.position = 'absolute';
    modalBoxClose.style.top = '0';
    modalBoxClose.style.right = '10px';
    modalBoxClose.style.display = 'block';
    modalBoxClose.style.width = '26px';
    modalBoxClose.style.padding = '5px';
    modalBoxClose.style.textAlign = 'center';
    modalBoxClose.style.cursor = 'pointer';
    modalBoxClose.style.borderBottomLeftRadius = '4px';
    modalBoxClose.style.borderBottomRightRadius = '4px';
    modalBoxClose.setAttribute('onclick', 'document.body.removeChild(document.getElementById(\'__modalBlocker\'));document.body.removeChild(document.getElementById(\'__modalBox\'));');

    //set up the dialog box title
    modalBoxTitle.innerHTML = dialogTitle;
    modalBoxTitle.style.display = 'block';
    modalBoxTitle.style.fontSize = '1.6em';
    modalBoxTitle.style.color = '#1797c0';
    modalBoxTitle.style.margin = '8px 0 0 8px';

    //Add the close button and the title to the modal box
    modalBox.appendChild(modalBoxClose);
    modalBox.appendChild(modalBoxTitle);
    modalBox.appendChild(modalBoxInner);

    //finally, add the modal box and the modal blocker to the page
    document.body.appendChild(modalBlocker);
    document.body.appendChild(modalBox);
}

<script>
Output


Apex variable to Display the value and change the css

Visualforce Page:

apex variable to Display the value and change the css .

<style>

.un_rvw{ color.green}
.incp {color.green}
</style>

<td style="text-align:left;">

<apex:outputPanel rendered="{!Case.Status != null}">

<apex:variable var="casePublicStatus" value="{!IF(Case.Status = 'Approved', 'Approved', IF(Case.Status = 'Rejected', 'Rejected', IF(Case.Status = 'Cancelled', 'Cancelled', IF(Case.Status = 'Application Complete', 'Completed', IF(Case.Status = 'Exit Confirmed', 'Exited', IF(Case.Status = 'Final Rejection' || Case.Status = 'Rejected' || Case.Status = 'Rejected by Immigration' || Case.Status = 'Rejected by Immigration 1' || Case.Status = 'Rejected by Immigration 2' || Case.Status =  'Rejected by Typing Dept' || Case.Status = 'Refund Issued', 'Rejected','In Process'))))))}"/>
<apex:variable var="casePStatus" value="{!Case.Public_Status_WF__c}"/>

<apex:variable var="caseCSS" value="{!IF(casePStatus= 'Approved', 'aprv',IF(casePStatus= 'Cancelled' || casePStatus= 'Rejected' || casePStatus= 'Warning', 'rjct', IF(casePStatus= 'Completed' || casePStatus= 'Exited', 'aprv',  IF(casePStatus= 'Pending Payment', 'pend',  IF(CONTAINS(casePStatus, 'Incomplete'), 'incp', 'un_rvw')))))}" />

<span class="sts {!caseCSS}" style="margin-left:-8px;">{!casePStatus}</span>

</apex:outputPanel>
</td>