Play Games

Search This Blog

Thursday, February 4, 2021

How to check if a record has access to the logged in user using SOQL query - Salesforce Globe For You

 How to check if a record has access to the logged in user using SOQL query?  - Salesforce Globe For You 

Problem: Assume a record exists in system,want to check if particular user has read,edit or delete access to that particular record.

Solution: use SOQL query as given below

SELECT RecordId , HasDeleteAccess , HasEditAccess , HasTransferAccess ,HasReadAccess from UserRecordAccess where RecordId=:recordId and UserId=:userId

where recordId is the salesforce recordId and userId is the userId of the user.

Example:Assume '0000000000' is the recordId and '00000000000' is the userId

SELECT RecordId , HasDeleteAccess , HasEditAccess , HasTransferAccess ,HasReadAccess from UserRecordAccess where RecordId='00000000000' and UserId='00000000000'

Output:



Tuesday, February 2, 2021

How to retrieve compact layout using package.xml in vs code salesforce

 How to retrieve compact layout using package.xml in vs code salesforce

Problem: Assume 'Custom_Compact_Layout' compact layout is created on Lead object as shown in the image below.Now we need to retrieve that compact layout in vs code tool using package.xml

Solution: Use name as CompactLayout and member as 'ObjectName.compactlayoutname' as shown below.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<Package xmlns="http://soap.sforce.com/2006/04/metadata">

    <types>

        <members>Lead.Custom_Compact_Layout</members>

        <name>CompactLayout</name>

    </types>

    <version>48.0</version>

</Package>

Output:



How to retrieve pageLayout using package.xml in vs code salesforce

Problem: Assume 'Custom Lead Page Layout' is created on Lead object as shown in the image below.Now we need to retrieve that pagelayout in vs code tool using package.xml

Solution: Use name as Layout and member as 'ObjectName-pagelayoutname' as shown below.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<Package xmlns="http://soap.sforce.com/2006/04/metadata">

    <types>

        <members>Lead-Custom Lead Page Layout</members>

        <name>Layout</name>

    </types>

    <version>48.0</version>

</Package>

Output:



How to retrieve custom Label using package.xml in vs code salesforce - Salesforce Globe For You

Problem: Assume a custom Label 'Custom_Label_Example' is created. Now we need to retrieve that label in vs code tool using package.xml

Solution: Use name as CustomLabel and member as customLabelApi as shown below.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<Package xmlns="http://soap.sforce.com/2006/04/metadata">

    <types>

        <members>Custom_Label_Example</members>

        <name>CustomLabel</name>

    </types>

    <version>48.0</version>

</Package>

Output: