Skip to main content

Posts

Showing posts from May, 2015

How to check accessibility of an user on a particular record ?

It is a very challenging requirement, Generally we will update records through trigger for complex requirement.  Lets think a scenario where we have to update a particular field value(say field name-IsUpdate) on an Opportunity and few profile is having editable access to that field,there is a already a trigger written for other purpose(updating some other thing) on Opportunity,So we have to modify same trigger and add our logic in that trigger. Our first and foremost approach  would be checking profile name in the condition as below. Approach-1(Using profile) Assume that profile "Test_profile_name" is having editable access to that field(IsUpdate) Profile ProfileName = [select Name from profile where id = :userinfo.getProfileId()]; for(Opportunity opp:trigger.new){      if(profileName.Name.containsIgnoreCase('Test_profile_name')){               // opp.IsUpdate = true;      } } It will work fine n...

How to call apex class from process builder?

As we all know it is not possible to invoke apex class from work flow,for that purpose sfdc lunched new functionality called process builder. Please go through this link. In my previous post i have explained about creation of process builder and updating a field through process builder. http://salesforceworld4u.blogspot.in/2015/04/updating-records-thorough-lightening.html Now this is post is all about calling an apex class from process builder. public class DeleteBrassCaseUtil{    @InvocableMetho d(label='Get Brass Cases Names' description='Returns the list of Brass Cases corresponding to the specified Brass Cases IDs.')   public static void deleteBrassCase(List<Id> BrassCaseIds)     {         List<BRASS_Case__c> brassCases =[SELECT Id,Is_Org_Case_Created__c...

How to get salesforce instance url in apex class?

This is quite simple to get but some developer used to hard code that instance url, Actually we should not hard code url like " https://cs12.salesforce.com " because it differs from org to org. Use below code to get instance url in apex class dynamically. String baseUrl = URL.getSalesforceBaseUrl().toExternalForm();