Showing posts with label Utility Tools. Show all posts
Showing posts with label Utility Tools. Show all posts

Sunday, August 20, 2017

Lightning Component to Display SetUp Audit Trail Data

As we know, SetUp Audit Trail allow us to track all the metadata changes happened to our org. Previously we have to download the SetUp Audit Trail history data from Salesforce UI in excel file.

SetUp audit trail data was not exposed in apex or through API in past but now salesforce has provided an option to query that data in apex or through API by introduction new object called "SetUpAuditTrail". This help us to find historical metadata changes specific to any action or any metadata changes done by any particular user.

I have created a lightning component which will display the SetUpAuditTrail data based on fileters provided by user. As of now, there is limited capability of sorting and filtering SetUpAuditTrail object records, I have used jquery datatable which will help us to sort records on all columns and also to filter records easily.

I have added the component to VF page by adding it to lightning app and exposed VF page through custom tab.

SetUpAuditTrail tracking VF page snapshot:



You can download complete code from below URL:
Lightning Component For SetUpAuditTrail Tracking

This is basic code for basic functionality. You can extend it as per your requirement.

Hope this will help!!!

Looking forward for everyone comments and suggestion!!

More Blogs>>: 
INHERITANCE IN LIGHTNING    
FIRING EVENT FROM LIGHTNING COMPONENT AND PASSING IT TO VF PAGE    
CHANGES TO LIGHTNING DATA SERVICE IN SUMMER'17    
LIGHTNING DATA SERVICES    
PASSING LIGHTNING COMPONENT ATTRIBUTE VALUE FROM VF PAGE    
FIRE LIGHTNING EVENTS FROM VF PAGE    
DYNAMICALLY CREATING AND DESTROYING LIGHTNING COMPONENTS    
RAISING AND HANDLING CUSTOM EVENTS IN sALESFORCE lIGHTNING    
WHY TO USE DESIGN RESOURCE AND HOW TO ADD DYNAMIC OPTION TO DATASOURCE    
PASSING LIGHTNING COMPONENT ATTRIBUTE VALUE FROM VF PAGE    
PASSING INNER WRAPPER CLASS TO LIGHTNING COMPONENT    
LIGHTNING COMPONENT FOR RECORDTYPE SELECTION FOR ANY SOBJECT    
CUSTOM COMPONENT TO SHOW/HIDE SPINNER IMAGE    

Sunday, January 15, 2017

Customizable Visualforce Component to display Hierarchy Relationship between records for any Object (Account Hierarchy, Case Hierarchy etc.)

It is very common use case to display hierarchy relation between records in tabular form (for example account hierarchy, case hierarchy etc.) In order to achieve this, I have created a reusable visualforce component for this purpose which can be customize as per requirement to display hierarchy in table tree grid.



Below are inputs required for component:
  1. Specify the object name for which you want to display hierarchy.
  2. Specify the parent field API name (used for self relationship).
  3. Specify the API names of fields separated by comma which you want to display in table tree grid.
  4. Specify the columns labels separated by comma (make sure sequence is same as that of API fields name )for table tree grid.
  5. Specify the field API name which will display as hyperlink for record detail page.

You can create new VF page and include this component and specify above inputs and component will display the hierarchy of record starting from top most parent. 

Below is visualforce component and apex class code:


For example to generate the account hierarchy, create a VF page with code :
<apex:page controller="hierarchyComponentController">
<c:hierarchyComponent sObjectAPIName="Account" sParentfieldAPIName="ParentId" ColumnsToDispaly="Name, Type, Industry" RecordLinkfieldAPIName="Name" ColumnsLabels="Account Name, Type, Industry"/>
</apex:page>

Note: Don't forget to append record Id on visualforce page url for which you want to display hierarchy. Below is sample URL:
https://xxxxxxxxx.visual.force.com/apex/accHierarchy?id=0019000001NqoXZ

Hope this will help...

This can be used as base code and can be customize as per your requirements.

Looking forward for everyone's comment and feedback.




Refer Below Links for Salesforce Interview Questions

Wednesday, October 19, 2016

Visualforce Component for Record Status Progress Bar

Sometimes we have to display current status of record through progress bar on record detail page. For example user can directly see the status of current opportunity or case by looking into detail page of record.




For this purpose we generally create a VF page and embed it in record page layout.

I have created a generic visualforce component which can be used to display record status bar. We just have to pass the object API name and field API name to component and it will generate status bar for you.

Upload below image image in static resource and name it as "progressbar".


Just create a new VF page and include this component in it. Below is code for visualforce Component and visualforce component Controller.


Suppose we need to display progress bar for opportunity stage, then use below code.

<apex:page standardController="Opportunity">
<c:StatusProgressBar objectAPIName="Opportunity"  fieldAPIName="stagename"/>
</apex:page>

Note:
  • You need to specify the objectAPIName and fieldAPIName for which you want to display progress bar.
  • Add this VF page to page layout to display progress bar.

Opportunity Record Detail Page



Now suppose you want to display progress bar for case record then create a VF page and use below code:

<apex:page standardController="Case">
<c:StatusProgressBar objectAPIName="Case" fieldAPIName="Status"/>
</apex:page>

Here we are displaying the progress bar for status field present in case. You can display status bar for any picklist field (standard or custom).



Friday, October 14, 2016

Batch Apex Job Progress Bar

We can display the progress of Batch Apex job on UI to user. Apex allows you to query the job status by query AsyncApexJob  object and getting all details about running job like status, JobItemsProcessed, NumberOfErrors, TotalJobItems etc. By using apex, we can manipulate the result and display the progress bar for batch job.

Suppose you already have Apex Batch class written. Here for example "RecordTypeAccessFinder" is batch class is already present.

Below is VF page and Apex class Code:



Friday, September 12, 2014

Using the Force.com CLI

Force.com CLI tool allows you to interact directly with Force.com from your command-line.
Functionality includes exporting metadata and packages created in SFDC to a local directory, browsing data objects, executing SOQL queries, executing APEX code,managing custom objects etc.


Download Force.CLI from https://force-cli.heroku.com/

Download Force.com CLI executable file and store it in some folder. Suppose my folder name is "CLI Demo" present in E: drive.


Now Open Command prompt  and go to CLI Demo Folder and use below commands:
E:\CLI Demo>force version


If you are getting version information then it means CLI is configured correctly. Otherwise if you getting some error, then set system variable by navigating computer->my properties-Advanced system settings->Environment variables. Provide CLI Demo folder location in path variable.


Once Force.com CLI is configured properly, then we can use it to export package created in SFDC to local directory. Follow below steps:
  1. Create a package: Go to SetUp-> Create->Packages. Create a new package and include all elements which you want to export from SFDC.
  2.          Now you can go to command prompt and enter following commands:
             First we need to login to SFDC instance in order to fetch package

        For Production and developer sandbox use
        force login -i=login.salesforce.com  -u=USERNAME  -p=PASSWORD+SECURITYTOKEN
                           or
        force login -u=USERNAME  -p=PASSWORD+SECURITYTOKEN

       For Sandbox
        force login -i=test.salesforce.com -u=USERNAME  -p=PASSWORD+SECURITYTOKEN

            To fetch package details:

      force fetch package PACKAGENAME --unpack

      In our case package name is “ForceCLIDemoPackage” so enter

      fetch package ForceCLIDemoPackage --unpack


Now metadata folder is created in CLI Demo folder which contain all components information present in package. If you open it, you will see package.xml containing all components list.


Note: If you deploy components in SFDC org using Workbench, then Force.com CLI will help you create package.xml file easily. You don’t have to manually create package.xml file. Just create package in your source org and Fetch it with Force.com CLI and the zip all contents (package.xml and all folders present in ForceCLIDemoPackage). After this deploy the zip file using workbench to target org.

Available commands:
   login     Log in to force.com
   logout    Log out from force.com
   logins    List force.com logins used
   active    Show or set the active force.com account
   whoami    Show information about the active account
   sobject   Manage standard & custom objects
   field     Manage sobject fields
   record    Create, modify, or view records
   bulk      Load csv file use Bulk API
   fetch     Export specified artifact(s) to a local directory
   export    Export metadata to a local directory
   fetch     Export specified artifact(s) to a local directory
   import    Import metadata from a local directory
   query     Execute a SOQL statement
   apex      Execute anonymous Apex code
   oauth     Manage ConnectedApp credentials
   version   Display current version
   update    Update to the latest version
   push      Deploy single artifact from a local directory
   password  See password status or reset password
   help      Show this help

Run 'force help [command]' for details.