Posts

Auto Number (Display Format) + Trigger

This needs to display into another field of the other object. However, when that record is created the field is generated with the Autonumber but not the display format of AAA-{0000}. Solution : -  trigger AutoNumbertrg on Account (before insert) {   Integer intCounter = 0 ;   Account lstAcc = [SELECT Id,AutoNumber__c FROM Account   Order BY Createddate DESC LIMIT 1];   if (!String.Isblank (lstAcc.AutoNumber__c)){       String s1 = lstAcc.AutoNumber__c;       system.debug('Test debug S1:  ' + s1 );       String sNumbers = s1.substringafter( '-');       System.debug('sNumbers ' + sNumbers );       i...

LIMIT_EXCEEDED, Maximum per user subscription limit reached (copy)

Problem :  Chatter EntitySubscription Limits ? In my project, we follow certain records via after update triggers, if some conditions match. I am getting this error on follow code that creates an EntitySubscription via trigger Description: Error:Apex trigger FollowXYZ caused an unexpected exception, contact your administrator: FollowXYZ: execution of AfterUpdate caused by: System.DmlException: Insert failed. First exception on row 0; first error: LIMIT_EXCEEDED, Maximum per user subscription limit reached.: []: Solution : Before Inserting the 'EntitySubscription' record, Get the count() subscription-id.  If the subscription-id count() is greater then 500, then delete the older EntitySubscription records first, then proceed with inserting the new EntitySubscription records. Code Snippet : 1) Count(userID) SELECT count()  FROM EntitySubscription   WHERE SubscriberId = '00530000005nnYnAAI'    AND ParentId IN...

Named Credentials - A turning point for callouts in Apex

What are Named Credentials? Specifies the URL of a callout endpoint and its required authentication parameters(methods & urls) with point & click. Can be seen as advance version of remote site settings in one scenario but it has totally different purpose. Remote site settings are not required for this. Named credentials handles all authentication requirements like headers to be set etc. It is an alternate of using remote site settings with apex code handling. It is much more secure. Supports two types of authentication protocols for now :  Basic Authentication(Password authentication) or OAuth. Can be configured easily if Authentication needs to be done in  User Context  or  Admin Context OAuth Protocol: This requires a proper setup of  Auth provider  in salesforce with configurations like consumer key, consumer secret, callback url. We can also connect two orgs with this method.To connect with another salesforce, connect...

Salesforce: Serial and Parallel Approval

Image
Approval process has been introduced in Salesforce platform sometimes back. But when someone ask you, if Salesforce support Parallel and Serial approval process? The answer is YES, although Salesforce do not implicitly said it is parallel or serial approval process. The good thing is, this functionality available out of the box. So you do not need to write any code. Just with point and click configuration, you can build this process within hours. Parallel Approval Parallel Approval means you are sending multiple approvals out in one step of the approval process. Any approver able to approve without need to wait for other approvers to approve. The approver can be specific  users ,  a queue  or  related user  in the record. How to configure this in Salesforce? When you reach Approval Steps -  Select Assigned Approver , choose  Automatically assign to approver(s) In sample above, when user submit for approval, it will go to a user 'Maria Ann' a...

Approval Process - Unanimous Approval Step

Unanimous Checkbox refers to each person or group within the approval process. Although the queue is made of many queue members, the queue counts as one approver, so whoever from the queue approves the record, is approving it on behalf of the entire queue.  So as the way the approval process is set up, this is unanimous approval.  In order to accomplish what you are trying to do each individual person would have to be named in the approval process. Then unanimous approval would require each individual person to approve before the approval goes through. This is similar to using a queue as a record owner, although there can be multiple members of the queue, the queue still only counts as one entity, not a group made up by its members. I hope that makes sense and helps.

What are Named Credentials?

Named Credentials were introduced by Salesforce in the Spring ’15 release. In this blog I will cover the basic functionalities of Named Credentials and why you should start using them today. The official description of named credentials in the  Salesforce help  is: A named credential specifies the URL of a callout endpoint and its required authentication parameters in one definition.  Salesforce  manages all the authentication for  Apex  callouts that specify a named credential as the callout endpoint, so that your code doesn’t have to. This means there are two major reasons to start using named credentials today: You no longer have to store your user credentials yourself anymore You no longer have to handle the authentication yourself anymore Let’s dive a little deeper into those two advantages. No longer store user credentials yourself Before named credentials were introduced, as a developer you had to store the user credenti...