<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>salesforce &#8211; Hamza Siddiqui</title>
	<atom:link href="https://www.mhamzas.com/blog/tag/salesforce/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.mhamzas.com</link>
	<description>4x Salesforce MVP &#124; 26x Certified &#124; Salesforce App &#38; System Architect</description>
	<lastBuildDate>Tue, 03 Jan 2023 08:14:48 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
<site xmlns="com-wordpress:feed-additions:1">233526040</site>	<item>
		<title>Dynamic Toggle Class in LWC</title>
		<link>https://www.mhamzas.com/blog/2020/07/08/dynamic-toggle-class-in-lwc/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=dynamic-toggle-class-in-lwc</link>
					<comments>https://www.mhamzas.com/blog/2020/07/08/dynamic-toggle-class-in-lwc/#respond</comments>
		
		<dc:creator><![CDATA[hamza]]></dc:creator>
		<pubDate>Wed, 08 Jul 2020 14:36:02 +0000</pubDate>
				<category><![CDATA[Salesforce]]></category>
		<category><![CDATA[lwc]]></category>
		<category><![CDATA[salesforce]]></category>
		<guid isPermaLink="false">https://www.mhamzas.com/?p=3157</guid>

					<description><![CDATA[This is a very simple scenario where you need to hide/show some div but you can&#8217;t use &#60;template if:true> tag. Let&#8217;s say you&#8217;re using loop. Here we&#8217;re discussing 2 approaches if you&#8217;re looking for answer to how you can use dynamic hide/show <br /><a href="https://www.mhamzas.com/blog/2020/07/08/dynamic-toggle-class-in-lwc/" class="more-link btn btn-primary">Read More</a>]]></description>
										<content:encoded><![CDATA[
<p>This is a very simple scenario where you need to hide/show some div but you can&#8217;t use &lt;template if:true> tag. Let&#8217;s say you&#8217;re using loop.</p>



<p>Here we&#8217;re discussing 2 approaches if you&#8217;re looking for answer to how you can use dynamic hide/show in LWC without template if:true approach</p>



<h2 class="wp-block-heading">Toggle Class (Simple Approach)</h2>



<script src="https://gist.github.com/mhamzas/454978473c593d8397c43fa0442d5dbf.js"></script>



<h2 class="wp-block-heading">Toggle (classList Approach)</h2>



<script src="https://gist.github.com/mhamzas/7dbb8633c7ee31102e1fe707651c4129.js"></script>



<p>Source <a href="https://salesforce.stackexchange.com/questions/260614/lwc-how-to-toggle-css-class-on-button-click">https://salesforce.stackexchange.com/questions/260614/lwc-how-to-toggle-css-class-on-button-click</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.mhamzas.com/blog/2020/07/08/dynamic-toggle-class-in-lwc/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3157</post-id>	</item>
		<item>
		<title>Checkbox label with URL in AURA/LWC</title>
		<link>https://www.mhamzas.com/blog/2020/06/05/checkbox-label-with-url-in-aura-lwc/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=checkbox-label-with-url-in-aura-lwc</link>
					<comments>https://www.mhamzas.com/blog/2020/06/05/checkbox-label-with-url-in-aura-lwc/#comments</comments>
		
		<dc:creator><![CDATA[hamza]]></dc:creator>
		<pubDate>Fri, 05 Jun 2020 12:47:39 +0000</pubDate>
				<category><![CDATA[Salesforce]]></category>
		<category><![CDATA[aura]]></category>
		<category><![CDATA[component]]></category>
		<category><![CDATA[lightning]]></category>
		<category><![CDATA[lwc]]></category>
		<category><![CDATA[salesforce]]></category>
		<guid isPermaLink="false">https://www.mhamzas.com/?p=3134</guid>

					<description><![CDATA[This is a pretty common use case where you want to show a simple checkbox to authorize the terms and condition with a URL to your terms of service or privacy url. But using lightning:input or lightning-input, we&#8217;re not allowed to add <br /><a href="https://www.mhamzas.com/blog/2020/06/05/checkbox-label-with-url-in-aura-lwc/" class="more-link btn btn-primary">Read More</a>]]></description>
										<content:encoded><![CDATA[
<p>This is a pretty common use case where you want to show a simple checkbox to authorize the terms and condition with a URL to your terms of service or privacy url. </p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img data-recalc-dims="1" decoding="async" width="369" height="43" src="https://i0.wp.com/www.mhamzas.com/wp-content/uploads/2020/06/image.png?resize=369%2C43&#038;ssl=1" alt="" class="wp-image-3135" srcset="https://i0.wp.com/www.mhamzas.com/wp-content/uploads/2020/06/image.png?w=369&amp;ssl=1 369w, https://i0.wp.com/www.mhamzas.com/wp-content/uploads/2020/06/image.png?resize=300%2C35&amp;ssl=1 300w" sizes="(max-width: 369px) 100vw, 369px" /></figure></div>



<p>But using lightning:input or lightning-input, we&#8217;re not allowed to add HTML tags under LABEL attribute.</p>



<p>So here are the work-arounds for AURA and LWC,</p>



<h2 class="wp-block-heading">AURA</h2>



<p>Component:</p>



<pre class="wp-block-code"><code>&lt;aura:attribute name="chkTerms" type="Boolean"/>
&lt;div>
    &lt;input type="checkbox" id="terms" name="terms" value="{!v.chkTerms}" onchange="{!c.termsChanged}" >&lt;/input>
    &lt;label for="terms"> Yes, by creating an account I agree to the &lt;a href="#">Terms and Service.&lt;/a>&lt;/label>
&lt;/div></code></pre>



<p>JS</p>



<pre class="wp-block-code"><code>termsChanged : function(cmp, event, helper){
    cmp.set("v.chkTerms", document.getElementById("terms").checked );
    //console.log(event.getSource().get("v.checked"));
    // the above didn't work except for `ui:input` or `lightning:input`
    console.log(cmp.get("v.chkTerms") ); 
}</code></pre>



<h2 class="wp-block-heading">LWC</h2>



<p>HTML</p>



<pre class="wp-block-code"><code>&lt;div class="slds-p-around_medium lgc-bg">
    &lt;input type="checkbox" id="terms" name="authorize" onchange={handleCheckBoxChange} required="required">&lt;/input>
    &lt;label for="terms" style="display: inline;" class="slds-form-element__label"> Yes, by creating an account I agree to the &lt;a href="#">Terms and Service.&lt;/label>
&lt;/div></code></pre>



<p>JS</p>



<pre class="wp-block-code"><code>handleCheckBoxChange(event){        
    console.log('Authorized::'+event.target.checked);
    // Your Logic
}</code></pre>



<p>Source <br><a href="https://salesforce.stackexchange.com/questions/213749/lightninginput-checkbox-label-with-url">https://salesforce.stackexchange.com/questions/213749/lightninginput-checkbox-label-with-url</a></p>



<p></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.mhamzas.com/blog/2020/06/05/checkbox-label-with-url-in-aura-lwc/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3134</post-id>	</item>
		<item>
		<title>Trailblazer Karachi Admin Group &#8211; April Virtual Meetup</title>
		<link>https://www.mhamzas.com/blog/2020/05/29/trailblazer-karachi-admin-group-april-virtual-meetup/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=trailblazer-karachi-admin-group-april-virtual-meetup</link>
					<comments>https://www.mhamzas.com/blog/2020/05/29/trailblazer-karachi-admin-group-april-virtual-meetup/#respond</comments>
		
		<dc:creator><![CDATA[hamza]]></dc:creator>
		<pubDate>Fri, 29 May 2020 18:10:24 +0000</pubDate>
				<category><![CDATA[Salesforce]]></category>
		<category><![CDATA[appexchange]]></category>
		<category><![CDATA[flows]]></category>
		<category><![CDATA[salesforce]]></category>
		<category><![CDATA[trailblazergroups]]></category>
		<guid isPermaLink="false">https://www.mhamzas.com/?p=3121</guid>

					<description><![CDATA[Trailblazer Karachi Admin Group &#8211; April Virtual Meetup Whether you&#8217;re an experienced Administrator, just getting started, want to learn more, we invite you to join in the fun. Mansoor Ahmed showed us some top free apps from app exchange for our daily <br /><a href="https://www.mhamzas.com/blog/2020/05/29/trailblazer-karachi-admin-group-april-virtual-meetup/" class="more-link btn btn-primary">Read More</a>]]></description>
										<content:encoded><![CDATA[
<p><strong>Trailblazer Karachi Admin Group &#8211; April Virtual Meetup</strong> Whether you&#8217;re an experienced Administrator, just getting started, want to learn more, we invite you to join in the fun. </p>



<p><strong>Mansoor Ahmed</strong> showed us some<strong> top free apps from app exchange</strong> for our daily use. </p>



<p><strong>Sandhya Bajaj</strong> helped us get started with <strong>Salesforce flows</strong> </p>



<p><strong>Presentations :</strong> Flows : https://docs.google.com/presentation/d/1RP-P8-fhRry0GAZeLuNkin3mC1rPcOwp1YX1_r7TJP8/edit?usp=sharing</p>



<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<div class="jetpack-video-wrapper"><iframe title="Trailblazer Karachi Admin Group – April Virtual Meetup" width="640" height="360" src="https://www.youtube.com/embed/sds6tHqBrwc?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></div>
</div></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://www.mhamzas.com/blog/2020/05/29/trailblazer-karachi-admin-group-april-virtual-meetup/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3121</post-id>	</item>
		<item>
		<title>Upserts with Generic sObjects &#8211; Salesforce</title>
		<link>https://www.mhamzas.com/blog/2019/12/13/upserts-with-generic-sobjects-salesforce/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=upserts-with-generic-sobjects-salesforce</link>
					<comments>https://www.mhamzas.com/blog/2019/12/13/upserts-with-generic-sobjects-salesforce/#respond</comments>
		
		<dc:creator><![CDATA[hamza]]></dc:creator>
		<pubDate>Fri, 13 Dec 2019 07:24:47 +0000</pubDate>
				<category><![CDATA[Salesforce]]></category>
		<category><![CDATA[apex]]></category>
		<category><![CDATA[salesforce]]></category>
		<category><![CDATA[sfdc]]></category>
		<category><![CDATA[sObject]]></category>
		<category><![CDATA[upsert]]></category>
		<guid isPermaLink="false">https://www.mhamzas.com/?p=3038</guid>

					<description><![CDATA[Have you ever run into this error? “Upsert with a field specification requires a concrete SObject type” Basically it is saying that you cannot declare a list of type sObject and then try to use the upsert command against that list. That <br /><a href="https://www.mhamzas.com/blog/2019/12/13/upserts-with-generic-sobjects-salesforce/" class="more-link btn btn-primary">Read More</a>]]></description>
										<content:encoded><![CDATA[
<p>Have you ever run into this error? “Upsert with a field specification requires a concrete SObject type”</p>



<p>Basically it is saying that you cannot declare a list of type sObject and then try to use the upsert command against that list. That limitation can make coding generic routines difficult which do not know the specific object type up front. For example, I might be building a table driven integration layer where the user will determine, by updating a custom field or custom setting, what the name of the destination custom object will be. With this approach I will need to use the generic sObject data type, but that will stop me from using the upsert database command.</p>



<p>Bummer! What to do?</p>



<p>Here is a&nbsp;<a href="http://salesforce.stackexchange.com/questions/61340/is-it-possible-to-upsert-a-listsobject-with-external-id-specified">link</a>&nbsp;that describes this problem very clearly and jangiz at the bottom describes the correct work-around approach.</p>



<p>Here is some code to implement that work-around that jangiz described:</p>



<script src="https://gist.github.com/mhamzas/eee6a82d5543ed6e853858d4156b1300.js"></script>



<p>Wow, what a bunch of work when I really just wanted to write…<br>upsert sObjList myExternalIDField</p>



<p>But as long as there is a manageable work-around I can at least move forward!</p>



<p>Good luck with your Apex today!</p>



<p>Source :  <a href="https://www.sundoginteractive.com/blog/generic-sobjects-salesforce">https://www.sundoginteractive.com/blog/generic-sobjects-salesforce</a> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.mhamzas.com/blog/2019/12/13/upserts-with-generic-sobjects-salesforce/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3038</post-id>	</item>
		<item>
		<title>Usage Of lightning-record-form</title>
		<link>https://www.mhamzas.com/blog/2019/11/18/usage-of-lightning-record-form/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=usage-of-lightning-record-form</link>
					<comments>https://www.mhamzas.com/blog/2019/11/18/usage-of-lightning-record-form/#respond</comments>
		
		<dc:creator><![CDATA[hamza]]></dc:creator>
		<pubDate>Mon, 18 Nov 2019 11:58:36 +0000</pubDate>
				<category><![CDATA[Salesforce]]></category>
		<category><![CDATA[lwc]]></category>
		<category><![CDATA[salesforce]]></category>
		<category><![CDATA[sfdc]]></category>
		<guid isPermaLink="false">https://www.mhamzas.com/?p=3015</guid>

					<description><![CDATA[Let us discuss&#160;here how&#160;to use the lightning-record-form . A&#160;lightning-record-form&#160;component enables you to quickly create forms to add, view, or update a record. Using this component to create record forms is easier than building forms manually with&#160;lightning-record-edit-form&#160;and&#160;lightning-record-view-form. However,&#160;lightning-record-form&#160;does not support client-side validation quite <br /><a href="https://www.mhamzas.com/blog/2019/11/18/usage-of-lightning-record-form/" class="more-link btn btn-primary">Read More</a>]]></description>
										<content:encoded><![CDATA[
<p>Let us discuss&nbsp;here how&nbsp;to use the lightning-record-form . A&nbsp;<code>lightning-record-form</code>&nbsp;component enables you to quickly create forms to add, view, or update a record. Using this component to create record forms is easier than building forms manually with&nbsp;<code>lightning-record-edit-form</code>&nbsp;and&nbsp;<code>lightning-record-view-form</code>. However,&nbsp;<code>lightning-record-form</code>&nbsp;does not support client-side validation quite the same as&nbsp;<code>lightning-record-edit-form</code>.The&nbsp;<code>object-api-name</code>&nbsp;attribute is always required, and the&nbsp;<code>record-id</code>&nbsp;is required unless you’re creating a record.</p>



<h2 class="wp-block-heading">Modes</h2>



<p>The component accepts a&nbsp;<code>mode</code>&nbsp;value that determines the user interaction allowed for the form. The value for&nbsp;<code>mode</code>&nbsp;can be one of the following:</p>



<ul class="wp-block-list"><li><code>edit</code>&nbsp;– Creates an editable form to add a record or update an existing one. When updating an existing record, specify the recordId. Edit mode is the default, and as such, can be omitted.</li><li><code>view</code>&nbsp;– Creates a form to display a record that the user can also edit. The record fields each have an edit button.</li><li><code>readonly</code>&nbsp;– Creates a form to display a record without enabling edits. The form doesn’t display any buttons.</li></ul>



<p>For all modes, the component expects the&nbsp;<code>fields</code>&nbsp;attribute, the&nbsp;<code>layout-type</code>&nbsp;attribute, or both. Use the&nbsp;<code>fields</code>&nbsp;attribute to specify a comma-separated list of record fields to load into the form. The fields load in the order you list them. Use the&nbsp;<code>layout-type</code>&nbsp;attribute to specify a&nbsp;<code>Full</code>&nbsp;or&nbsp;<code>Compact</code>&nbsp;layout. All fields that have been assigned to the layout are loaded into the form. This is the same behavior as the Lightning Data Service’s&nbsp;<code>force:recordData</code>&nbsp;object. Layouts are typically created or modified by administrators. Loading record data using&nbsp;<code>layout-type</code>&nbsp;allows the form to adapt to those layout definitions. If you provide the&nbsp;<code>fields</code>&nbsp;attribute and the&nbsp;<code>layout-type</code>&nbsp;attribute, the fields specified in the&nbsp;<code>fields</code>&nbsp;attribute are loaded before the layout fields.</p>



<p>This component takes care of field-level security and sharing for you, so users see only the data that they have access to.</p>



<h2 class="wp-block-heading">Creating a Record</h2>



<p>Use&nbsp;<code>mode="edit"</code>&nbsp;and pass in the object API name for the record to be created. Do not specify a recordId. Specify the fields using the&nbsp;<code>fields</code>&nbsp;attribute, or&nbsp;<code>layout-type="Full"</code>&nbsp;attribute to load all the fields defined on the full layout.The<em>&nbsp;compact layout cannot be used for creating records. If you&nbsp;</em>specify&nbsp;<em><code>layout-type="Compact"</code></em>,<em>&nbsp;the full layout is shown.</em>&nbsp;If you specify the&nbsp;<code>fields</code>&nbsp;attribute, be sure to include any fields that are designated as required for the object’s records. Because no recordId is passed, edit mode loads the form with input fields that aren’t populated with field data. The form displays Submit and Cancel buttons.This<em><strong>&nbsp;example creates an editable two-column form with the full layout and additional fields</strong></em>. The form is used for creating records in an Account object. The&nbsp;<code>onsubmit</code>&nbsp;attribute specifies an action to override the handler for the submit.</p>



<p>Create a Lightning web component&nbsp;using the below SFDX command</p>



<pre class="wp-block-code"><code>sfdx force:lightning:component:create --type lwc --componentname recordform --outputdir force-app\main\default\lwc</code></pre>



<p>Use the below recordform.html code</p>



<pre class="wp-block-code"><code>&lt;template>    
&lt;lightning-record-form object-api-name="Account" layout-type="Compact" columns="2" mode="edit"     onsuccess={handleSuccess} onsubmit={handleSubmit}>    
&lt;/lightning-record-form>&lt;/template></code></pre>



<p>Use the below recordform.js code</p>



<pre class="wp-block-code"><code>import {LightningElement,api} from 'lwc'; 
export default class Recordform extends LightningElement {     
  handleSubmit(event) {        
   console.log(event.detail)    
  }    
  handleSuccess(event) {        
   console.log('Record iD' + event.detail.id);     
  }
}</code></pre>



<p>Use the below recordform.js-meta.xml code</p>



<pre class="wp-block-code"><code>&lt;?xml version="1.0" encoding="UTF-8"?>
&lt;LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="helloWorld">    &lt;apiVersion>45.0&lt;/apiVersion>    
&lt;isExposed>true&lt;/isExposed>    
&lt;targets>        
  &lt;target>lightning__RecordPage&lt;/target>    
&lt;/targets>
&lt;/LightningComponentBundle></code></pre>



<p>Push the changes and add this component to the record page layout.&nbsp;you can able to see the complete record create a form</p>



<div class="wp-block-image"><figure class="aligncenter"><img decoding="async" src="https://i0.wp.com/rajvakati.com/wp-content/uploads/2019/02/Capture-36.png?resize=678%2C361&amp;ssl=1" alt="" class="wp-image-10355"/></figure></div>



<p>Now let’s see how to use create a record with specific fields. Now update the recordform.html code as shown below</p>



<pre class="wp-block-code"><code>&lt;template>    
&lt;lightning-record-form object-api-name={accountObject}  fields={myFields} mode="edit" onsuccess={handleSuccess} onsubmit={handleSubmit}>    
&lt;/lightning-record-form>
&lt;/template></code></pre>



<p>Use the below recordform.js code which will be passed to the record form.</p>



<pre class="wp-block-code"><code>import {LightningElement,api} from 'lwc';
import ACCOUNT_OBJECT from '@salesforce/schema/Account';
import NAME_FIELD from '@salesforce/schema/Account.Name';
import WEBSITE_FIELD from '@salesforce/schema/Account.Website';

export default class Recordform extends LightningElement {      
 accountObject = ACCOUNT_OBJECT;     
 myFields = &#091;NAME_FIELD, WEBSITE_FIELD];         
 handleSubmit(event) {        
  console.log(event.detail);    
 }    
 handleSuccess(event) {        
  console.log('Record iD' + event.detail.id);     
 }
}</code></pre>



<p>Push the changes and you can able to see the create form with two fields as shown below.</p>



<div class="wp-block-image"><figure class="aligncenter"><img decoding="async" src="https://i1.wp.com/rajvakati.com/wp-content/uploads/2019/02/Capture-37.png?resize=678%2C135&amp;ssl=1" alt="" class="wp-image-10357"/></figure></div>



<h2 class="wp-block-heading">Editing a Record</h2>



<p>If you do not specify the <code>mode</code> attribute, its default value is <code>edit</code>. To edit a record, pass the ID of the record and the corresponding object API name to be edited. Specify the fields using the <code>fields</code> attribute, or <code>layout-type</code> attribute to load all the fields defined on the Full or Compact layout. When <code>record-id</code> is passed, edit mode loads the form with input fields displaying the specified record’s field values. The form also displays Submit and Cancel buttons. This example creates an editable two-column form with a compact layout and additional fields. The form is used for editing records in an Account object. The <code>onsubmit</code> attribute specifies an action to override the handler for the submit. Update the recordform.html code as shown below.</p>



<pre class="wp-block-code"><code>&lt;template>    
&lt;lightning-record-form record-id={recordId} object-api-name="Account" layout-type="Full" columns="2" mode="edit" onsuccess={handleSuccess} onsubmit={handleSubmit}>    
&lt;/lightning-record-form>
&lt;/template></code></pre>



<p>update the recordform.js code as shown below.</p>



<pre class="wp-block-code"><code>import {LightningElement, api} from 'lwc'; 
export default class Recordform extends LightningElement {    
 @api recordId;    
 handleSubmit(event) {      
  console.log(event.detail);  
 }    
 handleSuccess(event) {       
  console.log('Record iD' + event.detail.id);    
 }
}</code></pre>



<p>Use&nbsp;<code>mode="view"</code>&nbsp;and pass the ID of the record and the corresponding object API name to be displayed. Specify the fields using the&nbsp;<code>fields</code>&nbsp;attribute, or&nbsp;<code>layout-type</code>&nbsp;attribute to display all the fields defined on the Full or Compact layout.</p>



<div class="wp-block-image"><figure class="aligncenter"><img decoding="async" src="https://i0.wp.com/rajvakati.com/wp-content/uploads/2019/02/Capture-38.png?resize=678%2C280&amp;ssl=1" alt="" class="wp-image-10360"/></figure></div>



<p>the following code shows the how to edit the specific fields instead of layouts.update the recordform.html code as below.</p>



<pre class="wp-block-code"><code>&lt;template>    
&lt;lightning-record-form object-api-name={accountObject} record-id={recordId}  fields={myFields} mode="edit"        
onsuccess={handleSuccess} onsubmit={handleSubmit}>    
&lt;/lightning-record-form>&lt;/template></code></pre>



<p>update the recordform.js code as shown below.</p>



<pre class="wp-block-code"><code>import {    LightningElement,    api} from 'lwc';
import ACCOUNT_OBJECT from '@salesforce/schema/Account';
import NAME_FIELD from '@salesforce/schema/Account.Name';
import WEBSITE_FIELD from '@salesforce/schema/Account.Website';

export default class Recordform extends LightningElement {     
@api recordId ;      
accountObject = ACCOUNT_OBJECT;     
myFields = &#091;NAME_FIELD, WEBSITE_FIELD];  
       
handleSubmit(event) {       
 console.log(event.detail);   
}    
handleSuccess(event) {       
 console.log('Record iD' + event.detail.id);    
 }
}</code></pre>



<p>Now you can able to see the changes as shown below with the specified fields.</p>



<div class="wp-block-image"><figure class="aligncenter"><img decoding="async" src="https://i0.wp.com/rajvakati.com/wp-content/uploads/2019/02/Capture-40.png?resize=678%2C142&amp;ssl=1" alt="" class="wp-image-10362"/></figure></div>



<h2 class="wp-block-heading">Viewing a Record Read-Only</h2>



<p>The simplest way to display a record is to use the&nbsp;<code>lightning-record-form</code>. You can display a record in two modes.<code>view</code>Loads the form using output fields with inline editing enabled. Editable fields have edit icons. If a user clicks an edit icon, all fields in the form become editable, and the form displays Submit and Cancel buttons.<code>read-only</code>Read-only mode loads the form with output fields only. The form doesn’t include edit icons, Submit and Cancel buttons.</p>



<p>This code displays an account record in view mode using the compact layout, which includes fewer fields than the full layout.</p>



<p>Use <code>mode="readonly"</code> and pass the ID of the record and the corresponding object API name to be displayed. Specify the fields using the <code>fields</code> attribute, or <code>layout-type</code> attribute to display all the fields defined on the Full or Compact layout. The read-only mode loads the form with output fields only, and without Submit or Cancel buttons.The following code specifis how to use the read-only mode. Use the below recordform.html code.</p>



<pre class="wp-block-code"><code>&lt;template>    
&lt;lightning-record-form record-id={recordId} object-api-name="Account"     
layout-type="Full" columns="2" mode="readonly"         
onsuccess={handleSuccess} onsubmit={handleSubmit}>    
&lt;/lightning-record-form>
&lt;/template></code></pre>



<p>You can able to see the record with read-only data .</p>



<div class="wp-block-image"><figure class="aligncenter"><img decoding="async" src="https://i2.wp.com/rajvakati.com/wp-content/uploads/2019/02/Capture-41.png?resize=678%2C283&amp;ssl=1" alt="" class="wp-image-10364"/></figure></div>



<p>Let’s update the code with view mode as shown below.&nbsp;<code>view&nbsp;</code>Loads the form using output fields with inline editing enabled. Editable fields have edit icons. If a user clicks an edit icon, all fields in the form become editable, and the form displays Submit and Cancel buttons.</p>



<p>Update the code as shown below and you can able to see the edit icon</p>



<pre class="wp-block-code"><code>&lt;template>    
&lt;lightning-record-form record-id={recordId} object-api-name="Account" layout-type="Full"     columns="2" mode="View" onsuccess={handleSuccess} onsubmit={handleSubmit}>    
&lt;/lightning-record-form>&lt;/template></code></pre>



<div class="wp-block-image"><figure class="aligncenter"><img decoding="async" src="https://i0.wp.com/rajvakati.com/wp-content/uploads/2019/02/Capture-42.png?resize=678%2C213&amp;ssl=1" alt="" class="wp-image-10366"/></figure></div>



<h2 class="wp-block-heading">Using Record types</h2>



<p>If your org uses record types, picklist fields display values according to your record types. You must provide a record type ID using the <code>record-type-id</code> attribute if you have multiple record types on an object and you don’t have a default record type. Otherwise, the default record type ID is used. Display a record create a form based on a record type by providing the <code>record-type-id</code> attribute. This example shows a form that you can place on an account record page. The form displays fields, which include a picklist with values based on the given record type Id.</p>



<pre class="wp-block-code"><code>&lt;lightning-record-form object-api-name={objectApiName} record-type-id={recordTypeId}                 fields={fields}>&lt;/lightning-record-form></code></pre>



<h2 class="wp-block-heading">Error Message</h2>



<p>To enable automatic error handling, include the component <code>lightning-messages</code>.To customize the behavior of your form when it loads or when data is submitted, use the <code>onload</code> and <code>onsubmit</code> attributes to specify event handlers. Errors are automatically handled. To customize the behavior of the form when it encounters an error on submission or when data is submitted successfully, use the <code>onerror</code> and <code>onsuccess</code> attributes to specify event handlers</p>



<pre class="wp-block-code"><code>&lt;template>            
&lt;lightning-messages>&lt;/lightning-messages>     
&lt;lightning-record-form record-id={recordId} object-api-name="Account" layout-type="Full"     columns="2" mode="View" onsuccess={handleSuccess} onsubmit={handleSubmit}>    
&lt;/lightning-record-form>&lt;/template></code></pre>



<p>Source :  <a href="https://rajvakati.com/2019/02/16/lightning-record-form/">https://rajvakati.com/2019/02/16/lightning-record-form/</a> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.mhamzas.com/blog/2019/11/18/usage-of-lightning-record-form/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3015</post-id>	</item>
		<item>
		<title>Apex Calling Methods In Lightning web components</title>
		<link>https://www.mhamzas.com/blog/2019/06/25/apex-calling-methods-in-lightning-web-components/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=apex-calling-methods-in-lightning-web-components</link>
					<comments>https://www.mhamzas.com/blog/2019/06/25/apex-calling-methods-in-lightning-web-components/#comments</comments>
		
		<dc:creator><![CDATA[hamza]]></dc:creator>
		<pubDate>Tue, 25 Jun 2019 10:48:37 +0000</pubDate>
				<category><![CDATA[Salesforce]]></category>
		<category><![CDATA[lightning]]></category>
		<category><![CDATA[lwc]]></category>
		<category><![CDATA[salesforce]]></category>
		<guid isPermaLink="false">https://www.mhamzas.com/?p=2883</guid>

					<description><![CDATA[Let’s discuss here how to call the apex class from the Lightning web components. Lightning web components can import methods from Apex classes into the JavaScript&#160;classes using ES6&#160;import. Once after importing the apex class method you can able call the apex methods <br /><a href="https://www.mhamzas.com/blog/2019/06/25/apex-calling-methods-in-lightning-web-components/" class="more-link btn btn-primary">Read More</a>]]></description>
										<content:encoded><![CDATA[
<p>Let’s discuss here how to call the apex class from the Lightning web components. Lightning web components can import methods from Apex classes into the JavaScript&nbsp;classes using ES6&nbsp;import. Once after importing the apex class method you can able call the apex methods as functions into the component by calling either via the wire service or imperatively. Before you use an Apex method, make sure that there isn’t an easier way to get the data. See whether a base Lightning component, like&nbsp;lightning-record-form,&nbsp;lightning-record-view-form, or&nbsp;lightning-record-edit-form&nbsp;works for your use case. If they don’t give you enough flexibility, use a wire adapter like&nbsp;getListUi&nbsp;or&nbsp;getRecordUi.&nbsp;</p>



<h4 class="wp-block-heading">Import Syntax&nbsp;</h4>



<p>You can able use&nbsp;default export&nbsp;syntax to import an Apex method via the&nbsp;@salesforce/apex&nbsp;scoped module into JavaScript&nbsp;controller class. The&nbsp;Syntax looks like below.Default</p>



<pre class="wp-block-code"><code>import apexMethod from '@salesforce/apex/Namespace.Classname.apexMethod';</code></pre>



<p><em><strong>apexMethod</strong></em>—The imported symbol that identifies the Apex method.<br><em><strong>Namespace</strong></em>—The namespace of the Salesforce organization. Specify a namespace unless the organization uses the default namespace (c), in which case don’t specify it.<br><em><strong>Classname</strong></em>—The name of the Apex class.</p>



<h4 class="wp-block-heading">Create Apex Class&nbsp;</h4>



<p>In this example, we will be getting account data and show it into the UI. Create an apex class using SFDX create apex class command.Default</p>



<pre class="wp-block-code"><code>sfdx force:apex:class:create -n GetAccountData -d force-app/main/default/apex</code></pre>



<p>Here is the apex class. To expose an Apex method to a Lightning web component, the method must be static and either global or public. Annotate the method with @AuraEnabledDefault</p>



<pre class="wp-block-code"><code>public with sharing class GetAccountData {
   @AuraEnabled(cacheable=true)
    public static List&lt;Account&gt; getAccountList() {
        return &#091;SELECT Id, Name,Type,Rating,Phone FROM Account];
    }
}</code></pre>



<p>Now you can able to call the apex class in&nbsp; Lightning web component using these different&nbsp;ways.</p>



<ul class="wp-block-list">
<li>Wire a property</li>



<li>Wire a function</li>



<li>Call a method imperatively</li>
</ul>



<h4 class="wp-block-heading">Wire an Apex Method to a Property</h4>



<p>If an Apex method is annotated with @AuraEnabled(Cacheable=true), you can invoke it from a component via the wire service. You can @wire a property or a function. Here is the syntaxDefault</p>



<pre class="wp-block-code"><code>import apexMethod from '@salesforce/apex/Namespace.Classname.apexMethod';
@wire(apexMethod, { apexMethodParams })
propertyOrFunction;</code></pre>



<p>Create a Lightning web component&nbsp;using below SFDX commandsDefault</p>



<pre class="wp-block-code"><code>sfdx force:lightning:component:create --type lwc -n LWCWireEx -d force-app/main/default/lwc</code></pre>



<p>Here is the&nbsp;LWCWireEx.html markup for the lightning web components.Default</p>



<pre class="wp-block-code"><code>&lt;template&gt;
    &lt;lightning-card title="Apex Class Example" icon-name="custom:custom63"&gt;
            &lt;div class="slds-m-around_medium"&gt;
                &lt;template if:true={accounts.data}&gt;
                    &lt;template for:each={accounts.data} for:item="acc"&gt;
                        &lt;p key={acc.Id}&gt;{acc.Name}&lt;/p&gt;
                    &lt;/template&gt;
                &lt;/template&gt;
                
            &lt;/div&gt;
        &lt;/lightning-card&gt;
&lt;/template&gt;</code></pre>



<p>Here is the&nbsp;LWCWireEx.js classDefault</p>



<pre class="wp-block-code"><code>import { LightningElement, wire } from 'lwc';
import getAccountList from '@salesforce/apex/GetAccountData.getAccountList';

export default class LWCWireEx extends LightningElement {
    @wire(getAccountList) accounts;
}</code></pre>



<p>Here is the&nbsp;LWCWireEx.js-meta.xml markup.Default</p>



<pre class="wp-block-code"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata"&gt;
    &lt;apiVersion&gt;45.0&lt;/apiVersion&gt;
    &lt;isExposed&gt;false&lt;/isExposed&gt;
    &lt;targets&gt;
        &lt;target&gt;lightning__RecordPage&lt;/target&gt;
       &lt;/targets&gt;
&lt;/LightningComponentBundle&gt;</code></pre>



<p>Push the changes to scratch org and add the lightning web component to the record page. You can able to see the result like below.</p>


<div class="wp-block-image">
<figure class="aligncenter"><img decoding="async" src="https://i2.wp.com/rajvakati.com/wp-content/uploads/2018/12/Capture-59.png?resize=612%2C322&amp;ssl=1" alt="" class="wp-image-8980"/></figure>
</div>


<h4 class="wp-block-heading">Wire an Apex Method to a Function</h4>



<p>Now let’s look at how to wire an apex method to function.we will be updating&nbsp;the same code here to operate the apex method as function.</p>



<p>Update the LWCWireEx.js class as shown&nbsp;belowDefault</p>



<pre class="wp-block-code"><code>import { LightningElement, wire,track } from 'lwc';
import getAccountList from '@salesforce/apex/GetAccountData.getAccountList';

export default class LWCWireEx extends LightningElement {
    @track accounts;
    @track error;
    @wire(getAccountList)
    wiredAccounts({ error, data }) {
        if (data) {
            this.accounts = data;
        } else if (error) {
            console.log(error);
            this.error = error;
        }
    }
}</code></pre>



<p>update the&nbsp;LWCWireEx.html markup as shown belowDefault</p>



<pre class="wp-block-code"><code>&lt;template&gt;

    &lt;lightning-card title="Apex Wire To Function Example" icon-name="custom:custom63"&gt;

        &lt;div class="slds-m-around_medium"&gt;
            &lt;template if:true={accounts}&gt;
                 &lt;ul&gt;
                &lt;template for:each={accounts} for:item="account"&gt;
                    &lt;li key={account.Id}&gt; {account.Name} &lt;/li&gt;
                &lt;/template&gt;
             &lt;/ul&gt;
            &lt;/template&gt;
            &lt;template if:true={error}&gt;
                {error}
            &lt;/template&gt;                
        &lt;/div&gt;
    &lt;/lightning-card&gt;
&lt;/template&gt;</code></pre>



<p>Push the changes to scratch org and add the lightning web component to the record page. You can able to see the result like below.</p>


<div class="wp-block-image">
<figure class="aligncenter"><img decoding="async" src="https://i1.wp.com/rajvakati.com/wp-content/uploads/2018/12/Capture-60.png?resize=607%2C324&amp;ssl=1" alt="" class="wp-image-8984"/></figure>
</div>


<h4 class="wp-block-heading">Call an Apex Method Imperatively</h4>



<p>Now let’s see here how to call apex method&nbsp;imperatively. Create a new Lightning web component using the below SFDX commandDefault</p>



<pre class="wp-block-code"><code>sfdx force:lightning:component:create --type lwc -n ImperativEx -d force-app/main/default/lwc</code></pre>



<p>Use the below ImperativEx.html codeDefault</p>



<pre class="wp-block-code"><code>&lt;template&gt;
        &lt;lightning-card title="Apex Imperative Method Example"&gt;
            &lt;div class="slds-m-around_medium"&gt;
                &lt;p class="slds-m-bottom_small"&gt;
                    &lt;lightning-button label="Load Accounts" onclick={handleLoad}&gt;&lt;/lightning-button&gt;
                &lt;/p&gt;
                &lt;template if:true={accounts}&gt;
                    &lt;template for:each={accounts} for:item="account"&gt;
                        &lt;p key={account.Id}&gt;{account.Name}&lt;/p&gt;
                    &lt;/template&gt;
                &lt;/template&gt;
                &lt;template if:true={error}&gt;
                   {error}
                &lt;/template&gt;
            &lt;/div&gt;
        &lt;/lightning-card&gt;
    &lt;/template&gt;</code></pre>



<p>Use the below ImperativEx.js class codeDefault</p>



<pre class="wp-block-code"><code>import { LightningElement, wire,track } from 'lwc';
import getAccountList from '@salesforce/apex/GetAccountData.getAccountList';


export default class ImperativEx extends LightningElement {
    @track accounts;
    @track error;
    handleLoad() {
        getAccountList()
            .then(result =&gt; {
                this.accounts = result;
            })
            .catch(error =&gt; {
                this.error = error;
            });
    }
}</code></pre>



<p>Use the below ImperativEx.js-meta.xml class codeDefault</p>



<pre class="wp-block-code"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="hello"&gt;
    &lt;apiVersion&gt;45.0&lt;/apiVersion&gt;
    &lt;isExposed&gt;false&lt;/isExposed&gt;
     &lt;targets&gt;
        &lt;target&gt;lightning__RecordPage&lt;/target&gt;
    &lt;/targets&gt;
&lt;/LightningComponentBundle&gt;</code></pre>



<p>push the changes to scratch org and add the lightning web component to the record page and you can able to see the below result when you click on the button .</p>


<div class="wp-block-image">
<figure class="aligncenter"><img decoding="async" src="https://i0.wp.com/rajvakati.com/wp-content/uploads/2018/12/Capture-61.png?resize=560%2C375&amp;ssl=1" alt="" class="wp-image-8987"/></figure>
</div>


<h2 class="wp-block-heading">Call an Apex Method with Parameters</h2>



<p>Pass parameters values to an Apex method in an object whose properties match the parameters of the Apex method. For example, if the Apex method takes a string parameter, don’t pass a string directly. Instead, pass an object that contains a property whose value is a string.</p>



<figure class="wp-block-image"><img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/resources.docs.salesforce.com/images/28232961511d39db2ddf9b5a0110df79.png?w=640&#038;ssl=1" alt="Enter characters in a seach field and click Search to return a list of contacts."/></figure>



<pre class="wp-block-code"><code><em>// apexImperativeMethodWithParams.js</em>

import { LightningElement } from 'lwc';
import findContacts from '@salesforce/apex/ContactController.findContacts';

export default class ApexImperativeMethodWithParams extends LightningElement {
    searchKey = '';
    contacts;
    error;

    handleKeyChange(event) {
        this.searchKey = event.target.value;
    }

    handleSearch() {
        findContacts({ searchKey: this.searchKey })
            .then((result) =&gt; {
                this.contacts = result;
                this.error = undefined;
            })
            .catch((error) =&gt; {
                this.error = error;
                this.contacts = undefined;
            });
    }
}</code></pre>



<pre class="wp-block-code"><code>public with sharing class ContactController {
    @AuraEnabled(cacheable=true)
    public static List&lt;Contact&gt; findContacts(String searchKey) {
        String key = '%' + searchKey + '%';
        return &#091;
            SELECT Id, Name, Title, Phone, Email, Picture__c
            FROM Contact
            WHERE Name LIKE :key AND Picture__c != NULL
            WITH SECURITY_ENFORCED
            LIMIT 10
        ];
    }
}</code></pre>
]]></content:encoded>
					
					<wfw:commentRss>https://www.mhamzas.com/blog/2019/06/25/apex-calling-methods-in-lightning-web-components/feed/</wfw:commentRss>
			<slash:comments>6</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2883</post-id>	</item>
		<item>
		<title>How I Passed Sharing &#038; Visibility Designer Exam</title>
		<link>https://www.mhamzas.com/blog/2019/03/28/how-i-passed-sharing-visibility-designer-exam/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-i-passed-sharing-visibility-designer-exam</link>
					<comments>https://www.mhamzas.com/blog/2019/03/28/how-i-passed-sharing-visibility-designer-exam/#respond</comments>
		
		<dc:creator><![CDATA[hamza]]></dc:creator>
		<pubDate>Thu, 28 Mar 2019 12:14:42 +0000</pubDate>
				<category><![CDATA[Salesforce]]></category>
		<category><![CDATA[certification]]></category>
		<category><![CDATA[salesforce]]></category>
		<category><![CDATA[sharing and visibilty]]></category>
		<guid isPermaLink="false">http://www.mhamzas.com/?p=2612</guid>

					<description><![CDATA[I finally sat the sharing and visibility designer exam and passed with a score of 82%. The exam really tested me on sharing, role hierarchy, territory management and apex sharing. Just one more exam to get my Application Architect. Update A lot <br /><a href="https://www.mhamzas.com/blog/2019/03/28/how-i-passed-sharing-visibility-designer-exam/" class="more-link btn btn-primary">Read More</a>]]></description>
										<content:encoded><![CDATA[
<p>I finally sat the sharing and visibility designer exam and passed with a score of 82%.</p>



<p>The exam really tested me on sharing, role hierarchy, territory management and apex sharing. Just one more exam to get my Application Architect.</p>



<p><strong>Update</strong></p>



<p>A lot of people asked for tips for this exam and rather than reply to everyone, I just posted here.</p>



<p>67% of the exam is on declarative sharing. So if you nail this section you have a good chance of passing.</p>



<ul class="wp-block-list"><li>Make sure you understand what Run as does in testing, as I had two questions on it.</li><li>Make sure you understand difference between territory management 1.0 and territory management 2.0</li><li>Do the security trailhead and remember that escape=false is a cross script issue and not using bind variables in SOQL is a SOQL injection issue. I had two questions on the topic.</li><li>Lots of questions on what happens to a manual share, if the record owner changes.</li><li>Lots of questions on why you should use a custom share reason for apex sharing.</li><li>Lots of question on data skew</li><li>Lot of questions on granular locking and deferred sharing calculation.</li></ul>



<h1 class="wp-block-heading">Salesforce Certified Sharing and Visibility Designer Exam Tips</h1>



<p><a href="http://www.alwaysablezard.com/salesforce/salesforce-certified-sharing-visibility-designer/">4th February 2018</a><a href="http://www.alwaysablezard.com/author/gemziebeth/">Gemma</a><a href="http://www.alwaysablezard.com/category/salesforce/architecture-certifications/">Architecture Certifications</a>,&nbsp;<a href="http://www.alwaysablezard.com/category/salesforce/">Salesforce</a></p>



<p>If you’ve ever been a Salesforce #AwesomeAdmin, you’ll find the Sharing and Visibility Designer exam to be one of the simpler ones. I’ve heard from a few developers lately that they, on the other hand, have found this to be one of the hardest in the architect pyramid. Well, with this blog post, I aim to take away some of the difficulty for you.</p>



<h1 class="wp-block-heading">What Sharing and Visibility Means</h1>



<p>The concept of Sharing and Visibility doesn’t just refer to permissions; in fact, there are a number of different features in Salesforce that contribute to data security. The architect certification aims to test your knowledge at a holistic level: given any scenario that they can throw at you, how would you achieve what the client wants?</p>



<p>As always, your best friend for this exam is the&nbsp;<a href="http://certification.salesforce.com/RG_CertifiedSharingandVisibilityDesigner.pdf">Resource Guide</a>. Here is a breakdown of things you need to know to pass.</p>



<h2 class="wp-block-heading">Sharing Architecture</h2>



<h3 class="wp-block-heading"><strong>Org-Wide Defaults (OWD)</strong></h3>



<p>These are applied per object (note that objects related via master-detail relationship will inherit the OWD from their parent). There are 3 types:</p>



<ul class="wp-block-list"><li>Public Read Write: A free-for-all; everyone can see and change any record</li><li>Public Read Only: Everyone can see and search for the record, but only the owner and those who are positioned&nbsp;above the owner in the role hierarchy can change it</li><li>Private: Only the owner and those above them in the role hierarchy can find or change the record</li></ul>



<p>The moment you have a requirement from somebody to keep a piece of data hidden away or uneditable for certain people, your OWDs need to be changed.</p>



<h3 class="wp-block-heading">Role Hierarchy</h3>



<ul class="wp-block-list"><li>Typical clients will try to set this up using their organisational structure – and that’s fine as long as that structure also reflects how data should be shared. Obviously, if everything is Read/Write, that matters a lot less.</li><li>Users are assigned a role when they’re first set up.</li><li>Note that if you have any users who will own millions of records, it’s best practice to make sure that user has&nbsp;<strong>no role</strong>, to optimise performance.</li><li>A typical role hierarchy could be:<ul><li>CEO&nbsp;<strong>(Cheryl)</strong><ul><li>COO&nbsp;<strong>(Colin)</strong><ul><li>VP of Sales&nbsp;<strong>(Sarah)</strong><ul><li>Field Sales Manager<ul><li>Field Sales Team Lead<ul><li>Field Sales Rep</li></ul></li></ul></li><li>Inside Sales Manager&nbsp;<strong>(Simon)</strong><ul><li>Inside Sales Team Lead&nbsp;<strong>(Denise)</strong><ul><li>Inside Sales Rep&nbsp;<strong>(Martin)</strong></li></ul></li></ul></li><li>Strategic Accounts Manager&nbsp;<strong>(David)</strong><ul><li>Strategic Accounts Team Lead<ul><li>Strategic Accounts Rep</li></ul></li></ul></li></ul></li><li>VP of Customer Service<ul><li>Customer Service Manager<ul><li>Customer Service Team Lead<ul><li>Customer Service Agent</li></ul></li></ul></li></ul></li></ul></li></ul></li></ul></li></ul>



<p>You get the picture. So if your OWD for Opportunities is Private, and the owner is Martin:</p>



<ul class="wp-block-list"><li>Martin can see and edit his own opportunities</li><li>Denise can see and edit her own opportunities, as well as Martin’s and any other Inside Sales Reps’ Opportunities</li><li>Simon can see and edit his own opportunities, as well as Martin’s, Denise’s&nbsp;and any other Inside Sales Reps’ Opportunities</li><li>Sarah can see and edit her own opportunities, as well as any Opportunity owned by any users beneath her – across field sales, inside sales and strategic accounts.</li><li>Colin can see exactly the same as Sarah. He wouldn’t usually own any opportunities of his own.</li><li>Cheryl has visibility across the entire organisation – as well as her own opportunities. Should Cheryl need to set up any opportunities of her own, they would&nbsp;<strong>only be visible and editable to her</strong>&nbsp;under this sharing model.</li></ul>



<p>Check out my Ladies Be Architects study group and quiz on sharing architecture:</p>



<figure><iframe width="780" height="439" src="https://www.youtube.com/embed/IBKd15GtrBM?enablejsapi=1&amp;autoplay=0&amp;cc_load_policy=0&amp;iv_load_policy=3&amp;loop=0&amp;modestbranding=0&amp;rel=1&amp;showinfo=1&amp;fs=1&amp;playsinline=0&amp;autohide=2&amp;theme=dark&amp;color=red&amp;controls=2&amp;" allowfullscreen=""></iframe></figure>



<h3 class="wp-block-heading">Sharing Grants</h3>



<p>Let’s say that for this example, our CEO Cheryl’s opportunities need to be shared with the Strategic Accounts Manager, David, as well as the VP of Sales, Sarah.</p>



<p>There are a few ways you could share Cheryl’s opportunities with these individuals:</p>



<ul class="wp-block-list"><li><strong>Sharing rules</strong>:<ul><li>Cheryl could have a blanket rule that says any opportunities she owns should automatically be shared with David and Sarah’s&nbsp;roles&nbsp;on a Read/Write basis.</li><li>Cheryl could also have a blanket rule that says any opportunities she manages with a Type of “Strategic” should automatically be shared with David and Sarah’s roles on a Read/Write basis</li></ul></li><li><strong>Manual sharing</strong>:<ul><li>Cheryl could just click “Sharing” and give Read/Write permission to David and Sarah. That’s useful on a case-by-case basis.</li></ul></li><li><strong>Team sharing</strong>:<ul><li>Adding David and Sarah to Cheryl’s default Account team would grant Read/Write access to Accounts owned by Cheryl, and their related opportunities (if that’s what’s needed)</li><li>Cheryl could also add David and Sarah to the Account team of any individual Accounts that she owns, thus granting access to the Account and related opportunities</li><li>Adding David and Sarah to the Sales Team of her opportunities on a case-by-case basis would grant Read/Write access</li><li>Note: the same can apply to Cases via Case Teams.</li></ul></li><li><strong>Apex sharing:</strong><ul><li>This is the sort of thing you’d want to do when you’ve exhausted all other options and the use case just doesn’t fit the above. Get a developer to write some fancy Apex.</li><li>Each object in the database also has a “share” table. Using Apex, a developer can add entries to a Share table and thus grant access.<ul><li><em>Example: a Project record with numerous objects related to it via Lookup. You want to share all related records with the owner – use an Apex sharing rule.</em></li></ul></li></ul></li></ul>



<h3 class="wp-block-heading">Account Territories</h3>



<p>Territory hierarchies are ways you can allocate an account to multiple territories, based on the structure of your sales strategy. Learn more about this in the Ladies Be Architects&nbsp;<a href="https://www.slideshare.net/gemziebeth/ladies-be-architects-study-group-i-territory-management">study group slides</a>. You will need to</p>



<ul class="wp-block-list"><li>Understand what the right use cases are for Territory Management</li><li>Understand the trade-offs if you choose to implement it</li><li>Have some practical experience of setting it up (even if you just mock it up in a trailhead playground, it helps)</li></ul>



<p>Ladies Be Architects’ first study group session took a look at Enterprise Territory Management in detail:</p>



<figure><iframe width="780" height="585" src="https://www.youtube.com/embed/FGd3npRb2HA?enablejsapi=1&amp;autoplay=0&amp;cc_load_policy=0&amp;iv_load_policy=3&amp;loop=0&amp;modestbranding=0&amp;rel=1&amp;showinfo=1&amp;fs=1&amp;playsinline=0&amp;autohide=2&amp;theme=dark&amp;color=red&amp;controls=2&amp;" allowfullscreen=""></iframe></figure>



<p>Sharing architecture is easily referred to in this handy pyramid that Salesforce provides in its&nbsp;<a href="http://resources.docs.salesforce.com/212/6/en-us/sfdc/pdf/sharing_architecture.pdf">Guide to Sharing Architecture</a>:</p>



<div class="wp-block-image"><figure class="aligncenter"><img decoding="async" src="https://i2.wp.com/www.alwaysablezard.com/wp-content/uploads/2018/02/Screen-Shot-2018-02-04-at-21.53.35.png?resize=414%2C290" alt="A guide to sharing architecture: Sharing and Visibility" class="wp-image-691"/></figure></div>



<h2 class="wp-block-heading">Security</h2>



<h3 class="wp-block-heading">Controlling access to Files</h3>



<p>Become familiar with the following concepts:</p>



<ul class="wp-block-list"><li>the File Owner</li><li>a File Collaborator</li><li>File Viewer</li></ul>



<p>…and the ways you can share files with these individuals.</p>



<h3 class="wp-block-heading">Why Salesforce has record owners</h3>



<p>There is a&nbsp;<a href="https://developer.salesforce.com/blogs/engineering/2013/10/behind-the-scenes-of-record-ownership-in-salesforce.html">great article</a>&nbsp;in the Resource Guide that will help you understand how and why Salesforce went against tradition and opted for an ownership model when it developed its platform. It also goes into great detail about how this works under the bonnet – I’d highly recommend studying this.</p>



<h3 class="wp-block-heading">Custom Permissions</h3>



<p>Custom permissions are pretty cool ways to restrict user permissions within a set use case.&nbsp;For example, according to the help guide, “…you can define access checks in Apex that make a button on a Visualforce page available only if a user has the appropriate custom permission.”. Just another handy tool when you’re designing applications.</p>



<h3 class="wp-block-heading">Controlling Access to Reports and Dashboards</h3>



<p>Know your folder access levels. For a bonus, understand that you can protect these further using two-factor authentication. Did you know you can force people to enter an authorisation code to view reports? Neither did I. It tends to come up in the Identity and Access Management exam, but is additionally useful for this one too.</p>



<h3 class="wp-block-heading">External Objects</h3>



<p>If you’re not familiar with Salesforce Connect, it’s time to get familiar. Study the guide, but remember these principles:</p>



<ul class="wp-block-list"><li>External objects are treated like custom objects in the API</li><li>External objects are a way to expose tables from an external database within Salesforce.<ul><li>You can add your own fields, but these fields are only populated inside Salesforce.</li><li>You can’t send this extra data back to its source; you’ll need to integrate via the API to do that.</li><li>They’re clever enough to link via an external ID.<ul><li>For example, if you’re exposing Orders from SAP in an external object and the order has a customer ID number you already keep in Salesforce, you can create an indirect lookup to link that Order record to an Account in Salesforce. Fancy!</li></ul></li></ul></li></ul>



<h2 class="wp-block-heading">Implicit Sharing</h2>



<p>Know what gets shared automatically and how. Difficult and lengthy to explain here, but&nbsp;<a href="https://developer.salesforce.com/docs/atlas.en-us.draes.meta/draes/draes_object_relationships_implicit_sharing.htm">this article</a>&nbsp;will explain the types of implicit sharing listed here:</p>



<ul class="wp-block-list"><li>Parent</li><li>Child</li><li>Boss</li><li>Portal</li><li>Community</li><li>Community Parent</li></ul>



<h2 class="wp-block-heading">Sharing Between Internal and External Users</h2>



<ul class="wp-block-list"><li>Sharing records<ul><li>Owned by high-volume community users (who don’t have roles) to internal and external users –&nbsp;<strong>share groups</strong>&nbsp;are your friends!</li><li>To high-volume community users (who don’t have roles) –&nbsp;<strong>sharing sets</strong>&nbsp;for the win! (“A sharing set grants high-volume users access to any record associated with an account or contact that matches the user’s account or contact.”)</li></ul></li></ul>



<h2 class="wp-block-heading">Encryption</h2>



<p>I’d highly recommend studying</p>



<ul class="wp-block-list"><li>best practices encrypting custom fields</li><li>the differences between platform encryption and classic encrypted fields</li><li>the Apex Crypto class</li></ul>



<h2 class="wp-block-heading">Handling Large Data Volumes</h2>



<p>If you’ve already passed the Data Architecture and Management certification exam, this should be easier than you’d expect. Here’s where the crossovers are:</p>



<ul class="wp-block-list"><li>Reducing the risk of lock contention</li><li>The impact of ownership skew and how it can be avoided</li><li>Group membership sharing<ul><li>setting up sensible public groups to optimise performance</li><li>avoiding too many records in the object’s share table by adding people to groups and sharing with the group<ul><li>As a rule, I tend to go<ul><li>Person —&gt; belongs to a Role</li><li>Role or Role and Subordinates —&gt; belongs to a public group</li><li>Territory —&gt; belongs to a public group</li><li>Group —&gt; belongs to a queue…..</li></ul></li></ul></li></ul></li></ul>



<p>but you can use other groups and individual users too. The principle is to try to share with the topmost level in your group architecture, but the&nbsp;<a href="https://developer.salesforce.com/blogs/engineering/2013/01/salesforce-group-membership-sharing-for-peak-performance.html">article provided by Salesforce</a>&nbsp;explains it much better than I can.</p>



<p>Overall, I found this to be an enjoyable exam which I look forward to studying again when I take my CTA certification!</p>



<p>References : <br></p>



<p>https://www.reddit.com/r/salesforce/comments/7x7zjb/i_passed_the_sharing_and_visibility_designer_exam/<br><br>http://www.alwaysablezard.com/salesforce/salesforce-certified-sharing-visibility-designer/</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.mhamzas.com/blog/2019/03/28/how-i-passed-sharing-visibility-designer-exam/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">2612</post-id>	</item>
	</channel>
</rss>
