Skip to main content

Posts

Showing posts from October, 2021

How to Identify whether Logged User has particular custom permission assigned ?

Earlier days we used to use Custom Permission in Visualforce page and Formula fields etc. We used to assign custom permission to a permission set. and We used to have one utility method to check whether user has permission set or not. public static  Boolean  doPermissoncheck( String  sPermissionName,  String  sUserId){      Boolean  isPermAssigned;      List < PermissionSetAssignment > lstOfAssignment      = [ SELECT   Id ,  PermissionSet . Name , AssigneeId   FROM   PermissionSetAssignment        WHERE   PermissionSet . Name  =:sPermissionName  AND   AssigneeId =:sUserId];     isPermAssigned = lstOfAssignment.isEmpty()? false : true ;      return  isPermAssigned;          } What If we want to know custom permi...

Apex programming Tricks

Convert List to Map  Lets assume we have list of accounts record and we need to create map of Id to Account record. Traditional  approach is using Iterating over list of Account records and storing in a Map. but the easiest approach is  List < Account > lstofAccount = [ Select  id,name  from   Account   limit   10 ]; system .debug( 'lstofAccount--' +lstofAccount); Map < Id , Account > map_account =  new   Map < Id , Account >(lstofAccount); system .debug( 'map_account--' +map_account); 11 : 00 : 02 : 011   USER_DEBUG  [ 4 ]| DEBUG | map_account--{ 00111000029360 TAAQ = Account :{ Id = 00111000029360 TAAQ ,  Name = Area   Agency   on   Aging   Region   9 ,  RecordTypeId = 012360000005 HcsAAE },  00111000029360 UAAQ = Account :{ Id = 00111000029360 UAAQ ,  Name = AULTMAN   HOSPITAL ,  RecordTypeId = 012360000005 HcsAAE }} Remove Dupl...

How to get record-Id in LWC screen action ?

 If you have created quick action and referred LWC component, you will get "Undefined" as Record Id in ConnectedCallback method, This is the issue I have come across.  connectedCallback() {         console.log( 'connected===============' );         console.log( this .recordId); // This will print undefined. } Solutions - 1: We can wrap LWC component with aura, and pass record Id. < aura:component   implements = "force:lightningQuickActionWithoutHeader, force:hasRecordId,force:appHostable >     < c:updateFiles   recordId="{!v.recordId}" /> </ aura:component > Solution - 2 Use RecordId in component html code. < div   style = "display:none" >      {recordId}   </ div > Component Controller import  {  LightningElement ,api,track }  from   'lwc' ; import  {  CloseActionScreenEvent...