Pages

Saturday 14 September 2019

Recycle Bin in Lightning Experience

In Winter '20 Salesforce release, Salesforce has introduced the accessibility of Recycle Bin in Lightning Experience. No longer have to switch to Salesforce Classic to access the Recycle Bin. We can now view, restore, and permanently delete the items in the personal or Org Recycle Bin.

How to access:
Access the Recycle Bin by selecting it in the App Launcher under All Items or personalizing your navigation bar. Or add the Recycle Bin tab for your org in the Lightning App Builder. 

The Recycle Bin in Lightning Experience works the same as it does in Salesforce Classic, except for a few differences. In Lightning Experience:

The org’s Recycle Bin is called Org Recycle Bin (1). The Salesforce Classic name is All Recycle Bin. 

Restore records by clicking Restore (2) instead of Undelete in Salesforce Classic. 

Permanently delete records by selecting them and clicking Delete (3) versus Undelete or Empty in Salesforce Classic. 

You can’t restore reports and dashboards. Switch to Salesforce Classic to access them in the Recycle Bin.














Tuesday 10 September 2019

Subscribe to Lightning Reports and Dashboards by Public Groups or Roles

In Spring '19 Salesforce extended the Report & Dashboard subscription beyond the user. Now, subscriptions can be done by Public Groups or Roles as well. This feature will help your recipient list stays current even when group membership or roles change.

A group subscription keeps your subscriber list current even when people join or leave the group. A role-based subscription keeps your subscriber list current even when people change roles.

In order to take the use of this feature, you must have the following user permissions enabled for your user:
  • To subscribe others to a dashboard, you need the Subscribe to Dashboards: Send to Groups and Roles permission
  • To subscribe others to a report, you need the Subscribe to Reports: Send to Groups and Roles user permission
  • To specify who runs the report in a report subscription, you need the Subscribe to Reports: Set Running User user permission.
How to verify:
When you’re setting up a report or dashboard subscription, click Edit Recipients.

  1. For the Entity Type, select the recipient type. 
  2. Start typing to see matching entries of the selected entity type and make a selection. 
  3. Click Add to add your selection to the list of subscribers

















Note: Only those User, Roles & Groups will be available for subscription who has the folder sharing. So, before the subscription make sure folder sharing is correct.

Monday 2 September 2019

Control the Lightning Component visibility using Permission Set / Custom Permission

At Dreamforce'18, Salesforce had announced lightning pages. This adds even more custom pages by hiding and displaying fields/components based on the criteria. It means that you could potentially have a one-page layout with all the differences being controlled by component visibility criteria. No more tons of different page layouts by profile!

With Lightning Component Visibility, we can decide if the component will display on the page for the user based on some set of criteria. A common practice is based on the user’s profile or username.

The example we have here is pretty simple.

The custom lightning component should only to be visible to a particular set of users within the profile.


1. Create new Custom Permission if it does not exist. Setup -> Custom Permission -> New.




 2. Go to the Lightning record page, set component visibility -> Filters. Choose Permissions -> Custom Permission and search for custom permission which was created in step 1. 












3. Create a new permission set and assign the custom permission to it.
4. Final Step, Assign the Permission set to the users.

Result:






Monday 19 August 2019

Validation rule to prevent the deletion of Record

Salesforce does not give any function to check for delete events in Validation rule e.g. ISDELETE() which could be similar to ISNEW().

There are many ways to achieve this, I know you would be thinking to write a trigger on before delete event and throw the error message. Yes, your thinking is correct, However, this can also be achieved without writing code. #powerofadmin

Let's consider a scenario. 
Opportunity line items cannot be deleted if the opportunity stage is closed-won.

1. Create new Roll-up summary field on Opportunity Object. This field will be used to count the total number of Opportunity Products on the Opportunity.


2. Create Validation rule on the Opportunity object. This rule will prevent the record delete if the Opportunity Stage is "Closed Won". 

Result:

Note: The above solution works for Master-Detail relationship between two objects.


Monday 15 July 2019

DocuSign for Salesforce: Display comma separated currency, number fields in DocuSign merge fields

When creating merge fields, commas are not populated into DocuSign tags when mapped from a currency or number field from Salesforce. 

Salesforce.com View:


Output from DocuSign:


As you can see, no commas are added in the values. Also, for the currency data, it does not contain commas or the dollar sign like it does in the Salesforce interface.

DocuSign is not formatting the value after it is received from Salesforce. Running the following SOQL query displays the true data values from the Salesforce database. 

SELECT Amount,Number_Field__c FROM Opportunity WHERE Id = '0061a000003oDge

Solution: 

  1. Create formula fields from Salesforce.
  2. Remap merge fields to point to the new formula fields​

Building Formula Fields

Currency Salesforce Field:

Example Formula:

IF(Amount < 0, "(", "") & "$" & IF(ABS(Amount) >= 1000000, TEXT(FLOOR(ABS(Amount) / 1000000)) & ",", "") & IF(ABS(Amount) >= 1000, RIGHT(TEXT(FLOOR(ABS(Amount) / 1000)), 3) & ",", "") & RIGHT(TEXT(FLOOR(ABS(Amount))), 3) & "." & IF(MOD(ABS(Amount) , 1) * 100 < 10, "0" & TEXT(ROUND(MOD(ABS(Amount) , 1), 2) * 100), TEXT(MIN(ROUND(MOD(ABS(Amount) , 1), 2) * 100, 99))) & IF(Amount < 0, ")", "")

Number Salesforce Field:

Example Formula:

CASE(LEN(TEXT( Number_Field__c )), 1, TEXT(Number_Field__c), 2, TEXT(Number_Field__c), 3, TEXT(Number_Field__c), 4, LEFT(TEXT(Number_Field__c), 1) & "," & RIGHT(TEXT(Number_Field__c), 3), 5, LEFT(TEXT(Number_Field__c), 2) & "," & RIGHT(TEXT(Number_Field__c), 3), 6, LEFT(TEXT(Number_Field__c), 3) & "," & RIGHT(TEXT(Number_Field__c), 3), 7, LEFT(TEXT(Number_Field__c), 1) & "," & MID(TEXT(Number_Field__c), 2,3) & "," & RIGHT(TEXT(Number_Field__c), 3), 8, LEFT(TEXT(Number_Field__c), 2) & "," & MID(TEXT(Number_Field__c), 3,3) & "," & RIGHT(TEXT(Number_Field__c), 3), 9, LEFT(TEXT(Number_Field__c), 3) & "," & MID(TEXT(Number_Field__c), 4,3) & "," & RIGHT(TEXT(Number_Field__c), 3), 10, LEFT(TEXT(Number_Field__c), 1) & "," & MID(TEXT(Number_Field__c), 2,3) & "," & MID(TEXT(Number_Field__c), 5, 3) & "," & RIGHT(TEXT(Number_Field__c), 3), 11, LEFT(TEXT(Number_Field__c), 2) & "," & MID(TEXT(Number_Field__c), 3,3) & "," & MID(TEXT(Number_Field__c), 6, 3) & "," & RIGHT(TEXT(Number_Field__c), 3), 12, LEFT(TEXT(Number_Field__c), 3) & "," & MID(TEXT(Number_Field__c), 4,3) & "," & MID(TEXT(Number_Field__c), 7, 3) & "," & RIGHT(TEXT(Number_Field__c), 3), null)

Remap Merge Fields:

Since the data you are attempting to pull is now located at a different field, you now need to reference this new formula field. Example below is when the original field was "Amount" from Salesforce.

Log into DocuSign: 
  1. Preferences 
  2. Custom Tags 
  3. Select merge field tag to update 
  4. Change to the formula field name



If your merge fields are added to templates. Delete the merge fields and add back in from your "custom" tag list.

Results:





Tuesday 25 June 2019

Delegate Approvers in Salesforce

This is very often that the Sales manager or director is out of the office and due to their absence, there are many approvals fall in the pending queue. As a result, this impacts the Sales cycle and business. Thanks to Salesforce! After reading this post, this problem will be fixed by using the power of delegation. In the absence of the Sales Manager, the delegated user can approve or reject the approvals assigned to the Sales Manager.

Fasten your seat belt and ready to learn the power of delegation in Salesforce.

Step 1: The existing approval process should have the option enabled for the delegation, refer the below screenshot.


Step 2: Set the Delegated approver (the user who can Approve/Reject the records in the absence of Actual Approver) by selecting the Approver in the Delegated Approver field on the user detail page.


Set your preference for receiving approval request emails. The options are:
  • If I am an approver or delegated approver
  • Only if I am an approver
  • Only if I am a delegated approver
  • Never—If you select this option, you won't receive any approval request emails, even if your organization has email approval response enabled. However, if the assignee of an approval step is a queue, selecting Never may not block all approval request emails, depending on the queue settings.

When an approval request email is sent to the assigned approver, the delegated approver also receives an email notification that there is an approval request to review. Delegated approvers can't reassign approval requests; they can only approve or reject approval requests.

Delegate Approvers can also approve/reject via an email.


Monday 10 June 2019

'List has no rows for assignment to SObject' error

The following query is not returning any number of records:
"[SELECT Id FROM Account WHERE Id = :Trigger.new[0].Account__c]"
The error "List has no rows for assignment to SObject" occurs when the query doesn't return any rows.

Player__c player = [SELECT Id from Player__c where Name = :username];
if (player != null)
 p = player.Id;
The above code will fail if there is no Player__c record with the matching username. It doesn't actually return a null.

It would be safer to do the following:

Player__c[] players = [SELECT Id from Player__c where Name = :username];
if (players.size() > 0)
p = players[0].Id;
It’s one of those situations for which you would not normally think of creating a test, so it’s safer to just avoid the possibility.

Enforce Field-Level Security in Apex (Pilot)

Apex has a new security feature for field-level data protection, which is accessed through the Security and SObjectAccessDecision classes. To ensure secure processing in Apex in the context of the current user’s read, create, or update operation, use the stripInaccessible method. Based on the field-level security of the current user, this method can be used to strip the fields from query results that the user can’t access. The method can also be used to remove inaccessible fields from sObjects before a DML operation to avoid exceptions and to sanitize sObjects that have been deserialized from an untrusted source.
How: The stripInaccesible method checks the source records for fields that don’t meet the field-level security check for the current user and creates a return list of sObjects. The return list is identical to the source records, except that the fields that are inaccessible to the current user are removed.

Example
If the user doesn’t have the permission to create the Probability field of an Opportunity object, this example removes the Probability field before creating the records. The DML operation is completed without throwing an exception.


List<Opportunity> opportunities = new List<Opportunity>{
    new Opportunity(Name='Opportunity1'),
    new Opportunity(Name='Opportunity2', Probability=95)
};

// Strip fields that are not creatable
SObjectAccessDecision decision = Security.stripInaccessible(
    AccessType.CREATABLE,
    opportunities);

// Print stripped records
for (SObject strippedOpportunity : decision.getRecords()) {
    System.debug(strippedOpportunity);
}

// print modified indexes
System.debug(decision.getModifiedIndexes());

// Print removed fields
System.debug(decision.getRemovedFields());

//System.debug Output
// DEBUG|Opportunity:{Name=Opportunity1}
// DEBUG|Opportunity:{Name=Opportunity2}
// DEBUG|{1}
// DEBUG|{Opportunity={Probability}}