Posts

Showing posts from October, 2019

Salesforce: Display map values in the Visualforce page

<apex:pageBlockTable value="{!recordMap}" var="record"> <apex:column headerValue="id" value="{!recordMap[record].Id}"/> <apex:column headerValue="name" value="{!recordMap[record].name}"/> <apex:pageBlockTable>

Salesforce: Pass the parameter from page block table to apex class

//Visualforce page pageblock table:     <apex:pageBlockTable value="{!recordList}" var="record">         <apex:column headerValue="ACTION" styleClass="fixedColumnWidth" headerClass="alignCenter">             <apex:commandButton action="{!removeRecord}" value="REMOVE" reRender="resultTable" status="popUpPageLoading">                 <apex:param name="selectedRecordId" value="{!record.Id}"/>             </apex:commandButton>         </apex:column>     <apex:pageBlockTable> //Apex Class public void removeRecord() {                String selectedRecordId = Apexpages.currentPage().getParameters().get('selectedRecordId'); }

Salesforce: Convert the date value in the logged in user local time format on Apex class

//Apex class Convert the time into local formate DateTime createdDate = [SELECT CreateDate FROM Account LIMIT 1].CreatedDate; Integer timeOffset = UserInfo.getTimezone().getOffset(createdDate); createdDate = createdDate.addSeconds(timeOffset/1000); 

Salesforce: Dynamically Assign the Salesforce standard icons in the Visualforce page

//VF Page code     <apex:pageBlockTable value="{!recordList}" var="record">         <apex:column headerValue="Icon">            <apex:image id="theImage" value="{!record.colorCode}"/>         </apex:column>     </apex:pageBlockTable> //Apex Class to get the values     public List<accountRecord> recordList {get; set;} public void getAccount() {    recordList = new List<accountRecord>();    for(Account record:[SELECT CreatedDate FROM Account]) {               String colorCode = (record.CreatedDate>System.Now().addDays(-3))?'/img/samples/flag_green.gif':(record.CreatedDate>System.Now().addDays(-5))?'/img/samples/flag_yellow.gif':'/img/samples/flag_red.gif';        recordList.add(new accountRecord(colorCode));    } } public cla...

Salesforce: Dynamically Assign the style in the Visualforce page

//CSS Style  .red {             background-color: red;         }         .green {             background-color: green;         }         .yellow {             background-color: green;         }       //VF Page code     <apex:pageBlockTable value="{!recordList}" var="record">         <apex:column styleClass="{!record.colorCode}" headerValue="Created Date">            {!record.createdDate}         </apex:column>     </apex:pageBlockTable>       //Apex Class to get the values    public List<accountRecord> recordList {get; set;} public void getAccount() { recordList = new List<accoun...

Salesforce: Pagination in Visualforce Page

Pagination on the Visualforce page: //Created First,Next,Last,Previous button along with number of record count  <apex:outputPanel rendered="{!taskTotalRecordCount>0}" layout="block" styleClass="pageblockIconBlock">         <apex:commandButton styleClass="pageblockIconStyle" value="<<" status="pageLoading" rerender="resultTable" action="{!FirstPageCompletedTaskData}" disabled="{!preveviousdata}"/>         <apex:commandButton styleClass="pageblockIconStyle" value="<" status="pageLoading" rerender="resultTable" action="{!PreviousPageCompletedTaskData}" disabled="{!preveviousdata}"/>                <apex:outputText style="padding-left:15px;padding:5px;" >&nbsp;&nbsp;{!(taskCompletedRecordOffsetSize+1)}-{!IF((taskCompletedRecordOffsetSize + taskCompletedRecordLimitSize)>taskTota...

SALESFORCE: Dynamically assign the approval process record to different user using Apex class

Dynamically assign the approval process to the different user using apex class: STEPS : //Get the approval process instance workitem record, which has a current approver details List<ProcessInstanceWorkitem> processInstanceWorkItemList = [select ProcessInstanceId,actorId from ProcessInstanceWorkitem where ProcessInstance.TargetObjectId=********MENTION THE TARGET OBJECT RECORD ID********]; //Assign the user or group id whom you want to assign the approval process processInstanceWorkItemList[0].actorId=********MENTION THE USER/GROUP RECORD ID********; //Update the list, it will internally create the new record in ProcessInstanceStep to capture the latest user detail and update the current approver in the approval process update processInstanceWorkItemList;