Override Approve and Reject Button of Approval Process in VF Page

1.) Can we control the approve and Reject Button in Visualforce page ?

Yes you can control by creating custom approval and reject button in visualforce page.

2.) Can we remove the standard approve and reject Button in approval process Related list?

approved

Yes you can hide by using JavaScript and instead of this you can create Command buttons in VF page for approve and reject. Control the button action in controller behind.

Code for Hiding Approve,Reject and Submit for approval by using Javascript :

We need to get the column id of Approve,Reject and Submit for approval like the below screenshot and use the column Id in javascript like below to Hide it.

inspect hide approve

<apex:relatedList list="ProcessSteps"/>
<script src="https://code.jquery.com/jquery-3.2.1.min.js" type="text/javascript"></script> 
<script type="text/javascript"> 
 $( document ).ready(function() {    
 $(".actionColumn").css("display","none"); //Approve and Reject Hide 
 $("input[name='piSubmit']").css("display","none"); //Submit for approval }); </script>

Formulas & Validation Rules

student_board_formula_solution_80802_1920x1080

Validation Rule for Case not closed in Queue:

AND(
NOT(ISBLANK(Owner:Queue.Id)),
ISPICKVAL(Status, "Closed")
)

 Calculate the end date of the month Based on the start date of the month:

DATE(
YEAR(Start_date__c),
MONTH(Start_date__c),
CASE( MONTH(Start_date__c),
1, 31,
2, IF( MOD( YEAR(Start_date__c), 4) = 0, 29, 28),
3, 31,
4, 30,
5, 31,
6, 30,
7, 31,
8, 31,
9, 30,
10, 31,
11, 30,
12, 31,
0
)
)

Calculate Total hours from Date:

TEXT(
FLOOR(Current_Time__c - CreatedDate) *24
) & " Hours "

Calculate Date, Minutes, Hours:

TEXT(
FLOOR(Current_Time__c - CreatedDate)
) & " Days " &
TEXT(
ROUND(MOD((Current_Time__c - CreatedDate)*24,24),0)
) &" Hours " &
TEXT(
ROUND(MOD((Current_Time__c- CreatedDate)*1440,60),0)
) &" Minutes "

Merge five picklist field values into one formula field:

SUBSTITUTE(
IF(ISBLANK(TEXT(Picklist_1__c)), NULL, TEXT(Picklist_1__c)+ ", ")+
IF(ISBLANK(TEXT(Picklist_2__c)), NULL, TEXT(Picklist_2__c)+ ", ")+
IF(ISBLANK(TEXT(Picklist_3__c)), NULL, TEXT(Picklist_3__c)+ ", ")+
IF(ISBLANK(TEXT(Picklist_4__c)), NULL, TEXT(Picklist_4__c)+ ", ")+
IF(ISBLANK(TEXT(Picklist_5__c)), NULL, TEXT(Picklist_5__c)+ ", ") + ".",
", .",
NULL
)

How to track the Case Age of each Status

Calculate Time spent on Case Status By David Litton.I had Implemented this. Good way to Go and Got Expected Results

Salesforce Sidekick

I’ve been running into many scenarios where people want to track the Age of each status (be it Case or another Custom Object).  We’ve got things like Field Tracking that we can use to get close, but the data isn’t very easy to build dashboards and reports on.  So, my mind immediately went back to one of my first posts and Flows, Case Time Tracking.  In this post we were wanting to see how long the Users had worked on a Case, and not how long our Cases were staying in a status.  But architecturally we’re going to be pretty similar.

Automation Overview:

  1. Case Meets Criteria – Process Builder triggered (Pass inputs into Visual Flow)
  2. Flow Checks to see if existing open Record
  3. Flow Updates existing record if possible
  4. Flow Checks to see if Case is still Open, exists if Closed
  5. If Case is Open, Flow creates new Record

We…

View original post 795 more words

Query To undelete Bulk Records

Recently I had Faced This Issue:

My Records More Than 3-lakhs got deleted in Account object while running a query in Developer Console(Execute Anonymous Window)for multiple times.So I thought that I have only one way to  undelete it.By Going in to Recycle Bin undelete Records Individually.so that’s not Fair Idea to do it for More than 3Lakhs of Records.

Solution:

I got solution that this can be done by Coding.So I ran a query to check whether Retrieved Records are Correct.By running a Code maximum Limit of 10 Thousand Record is Retrieved.So I ran a query for 30+times to undelete the Records Completely.

List<Account> recordToUndelete= [SELECT Id, Name FROM Account WHERE
 IsDeleted = True AND LastModifiedDate = Today LIMIT 10000 ALL ROWS];

System.debug(recordToUndelete.size());
try
{
//attempt to undelete the records
undelete recordToUndelete;
}
//To Catch and Display DML Exceptions
catch(DMLException ex)
{
System.Debug(ex);
}
//To catch and Display Exceptions
catch(Exception e)
{
System.Debug(e);
}

Spring ’17 Customization

Approvals:

1.) Review Pending Approval Requests from Lightning Experience:

  •  Lightning Experience can review their pending approval requests in one place. This change applies to Lightning Experience only.
  • Edit the appropriate home pages in Lightning App Builder to add the Items to Approve component or app navigation bar.

approvals_tab

2.) Don’t Worry About That Submit Button:

  • Automatically add the button to all the associated page layouts when you activate an approval process. This change applies to both Lightning Experience and Salesforce Classic.
  • When you create an approval process, look for this setting: Add the Submit for Approval button and Approval History related list to all Object page layouts. Previously, the setting added only the Approval History related list to the object’s page layouts, and it was disabled by default. It now includes the Submit for Approval button and is enabled by default.

  • This setting is available only when you create an approval process. When the setting is enabled, Salesforce adds the Submit for Approval button to the Standard Buttons section of that object’s page layouts.

Process Builder

1.) Process Builder Has Updated Icons:

Winter 17—->>pb_icons_list_before

Spring 17—->> pb_icons_list_after

2.) Access Encrypted Data in Process Builder:

  • Process Builder now supports encrypted fields, except in filters, like in the Update Records action. This change applies to both Lightning Experience and Salesforce Classic.
  • If you’re an existing pilot customer, nothing has changed since the last release.

Ex: If you’ve encrypted Account Name, you can update that field’s value, but you can’t filter based on that field.

Picklist Administration:

1.) Global Picklist Fields Now Have Their Own Record Type:

All global picklist fields that use the same global value set now have individual record types. This change gives you more flexibility than having only one record type for all fields.

2.) Value Labels Are No Longer Tied to API Names:

  • picklist value has a display label and an API name.
  • change the label without the API name changing.
  • You can also edit the API name.
  • you can disable the ability to change API names.

    prevent users from changing a picklist value’s API name:

  1.   Setup in Salesforce Classic, enter Picklist Settings in the Quick Find box.
  2.   Select Disable editing picklist values’ API names.

3.) Access Picklists with the Tooling API:

Standard and global value sets are now available in the Tooling API and Metadata API.

       New Tooling API items are:

  • StandardValueSet—Represents the set of values in a standard picklist field.
  • GlobalValueSet—Represents the definition of a value used in a global value set or local custom picklist.

Note:

This feature isn’t generally available unless or until Salesforce announces its general availability in documentation or in press releases or public statements. We can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

Spring ’17 -Set Up Sales Cloud Einstein

einstein-3

To set up Sales Cloud Einstein user Permission Needed “Customize Application” and “Modify All Data”

    Note:

  1. Your org must use a public sharing model for leads and contacts.
  2. Purchase Sales Cloud Einstein.
  3. Salesforce installs two packages in your org, SalesforceIQ Cloud and Sales Insights. Each package adds an associated integration user and profile. Salesforce uses these entities to provide insights to your org. If you update these entities, it may affect your org’s ability to get insights.

    Steps to setup Einstein:

  1. From Setup, enter Setup Assistant in the Quick Find box, then select Setup Assistant under Sales Cloud Einstein.
  2. Select who can use Einstein.
    1. Create a permission set.
    2. From the License drop-down list, select Sales Cloud Einstein.

einstein_license

 

c.) Click Save.

d.) Click App Permissions.

e.) Enable app permissions for Einstein features.

einstein_permissionset_apppermissions

 

              f.)Assign the permission set to users.

3.) From the Einstein Setup Assistant, enable Einstein features.
If you enabled Automated Activity Capture, Salesforce asks Einstein users to connect their Google™ or Microsoft® Office 365® account to Salesforce. It takes up to 24 hours for their emails and events to be initially added to Salesforce.

4.) Using the Lightning App Builder, add the Einstein component to the Home page and to Lightning pages for accounts, leads, and opportunities.
Einstein users see insights on the Einstein component. It takes up to 24 hours for insights to be available.

5.) After insights are available, add the Score field to any public lead list views. Salesforce automatically adds it to your default list view.

Note:

  1. Tell sales reps to set the Sharing Setting for All Emails and Events to Everyone to get the most out of Opportunity Insights.
  2. Tell sales reps to add the Score field to their list views to get the most out of Lead Insights

Trigger to Auto populate Opportunity Name with Account Name

Scenario:

Write a Trigger to Auto populate Opportunity Name with Account Name, Today Date,1year from Todays Date while creating New Record.

Apex Class:

public class FetchAccName {
    public  void fetchaccount(List<Opportunity> NewOpps) {

    List<Id> oppIds = new List<Id>();
        for (Opportunity opp:NewOpps ){
             oppIds.add(opp.Id);
        }
    List<Opportunity> oppr = [select id , Name,Account.Name From Opportunity Where id in :oppIds];
                  for(Opportunity opps : oppr){
                        date myDate = date.Today();
                        Integer month = myDate.month();
                        Integer day = myDate.day();
                        Integer year = myDate.year();
                        opps.Name = (opps.Name +'::'+ opps.Account.Name +'::' +' '+day+'-'+month+ '-'+year+'::'+' '+day+'-'+month+ '-'+(year+1));
                    }       

    Update oppr;
    }
}
 

Trigger:

 trigger FetchAccountname on Opportunity (After insert) {
FetchAccName fa = new FetchAccName();
fa .fetchaccount(trigger.new);
}

Test Class:

@isTest
private class FetchAccountNameTest  {

	private static testMethod void opportunity() {
	       List<Opportunity> oList = new List<Opportunity> {
                   new Opportunity(Name ='00New mAWS Deal',
                                   StageName = 'Customer Won',
                                   Amount = 3000,
                                   CloseDate = System.today()
                        )
  };
  insert oList;
}
 

Detail Edit Page:

opportunu

Output Detail Page:

output-opp