<?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>aura &#8211; Hamza Siddiqui</title>
	<atom:link href="https://www.mhamzas.com/blog/tag/aura/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>Fri, 05 Jun 2020 12:47:40 +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>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>Platform Events in Lightning Component</title>
		<link>https://www.mhamzas.com/blog/2020/04/21/platform-events-in-lightning-component/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=platform-events-in-lightning-component</link>
					<comments>https://www.mhamzas.com/blog/2020/04/21/platform-events-in-lightning-component/#respond</comments>
		
		<dc:creator><![CDATA[hamza]]></dc:creator>
		<pubDate>Tue, 21 Apr 2020 10:04:03 +0000</pubDate>
				<category><![CDATA[Salesforce]]></category>
		<category><![CDATA[aura]]></category>
		<category><![CDATA[platformevent]]></category>
		<guid isPermaLink="false">https://www.mhamzas.com/?p=3088</guid>

					<description><![CDATA[Platform Events are used to deliver secure, scalable, and customizable notification within Salesforce or external app. Platform Event is based on Event-Driven Architecture. This is built in real time integration patterns&#160;in the Salesforce Platform which&#160;helps&#160;to reduce point-to-point integration. WHEN TO USE PLATFORM <br /><a href="https://www.mhamzas.com/blog/2020/04/21/platform-events-in-lightning-component/" class="more-link btn btn-primary">Read More</a>]]></description>
										<content:encoded><![CDATA[
<p>Platform Events are used to deliver secure, scalable, and customizable notification within Salesforce or external app. Platform Event is based on Event-Driven Architecture. This is built in real time integration patterns&nbsp;in the Salesforce Platform which&nbsp;helps&nbsp;to reduce point-to-point integration.</p>



<h4 class="wp-block-heading"><strong>WHEN TO USE PLATFORM EVENTS?</strong></h4>



<ol class="wp-block-list"><li>Platform events are very useful when you want to communicate Salesforce with any external system.</li><li>Platform events are also used to communicate between two lightning applications.</li><li>Platform events are very useful when you want to communicate between two visualforce pages.</li></ol>



<h4 class="wp-block-heading"><strong>SUBSCRIPTION IN PLATFORM EVENT:&nbsp;</strong></h4>



<ol class="wp-block-list"><li>Apex triggers receive event notifications.</li><li>write an&nbsp;“after insert”&nbsp;Apex trigger on the event object to subscribe to incoming events.</li><li>Triggers receive event notifications from various sources—whether they’re published through Apex or APIs.</li><li>Visualforce and Lightning component apps receive events through CometD.</li><li>CometD is a scalable HTTP-based event routing bus that uses an AJAX push technology pattern known as Comet.</li><li>In an external app, you subscribe to events using CometD as well.</li></ol>



<h4 class="wp-block-heading">CREATING PLATFORM EVENT OBJECT</h4>



<p>Setup —-&gt; Platform Event —-&gt; New</p>



<p>Create Notification__e Platform event</p>



<figure class="wp-block-image"><img data-recalc-dims="1" decoding="async" src="https://innovateforce.files.wordpress.com/2019/04/capture-1.png?w=640" alt="" class="wp-image-175"/><figcaption>Creation of Platform Event Notification__e</figcaption></figure>



<p>Create a Lightning Component to display toast based on Platform event Creation</p>



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



<p>The&nbsp;<code>lightning:empApi</code>&nbsp;component provides access to methods for subscribing to a streaming channel and listening to event messages. All streaming channels are supported, including channels for platform events, PushTopic events, generic events, and Change Data Capture events. The&nbsp;<code>lightning:empApi</code>&nbsp;component uses a shared CometD connection.</p>



<p>To call the component’s methods, add the&nbsp;<code>lightning:empApi</code>&nbsp;component inside your custom component and assign an&nbsp;<code>aura:id</code>&nbsp;attribute to it.</p>



<p>Add this lightning component in lightning app utiliy bar</p>



<p>Once Platform event record get Created, A toast message is displayed</p>



<figure class="wp-block-image"><img data-recalc-dims="1" decoding="async" src="https://innovateforce.files.wordpress.com/2019/04/capture-2.png?w=640" alt="" class="wp-image-176"/></figure>



<p>Source : <a href="https://sfdcrecipes.com/2019/04/13/platform-events-in-lightning-component/">https://sfdcrecipes.com/2019/04/13/platform-events-in-lightning-component/</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.mhamzas.com/blog/2020/04/21/platform-events-in-lightning-component/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3088</post-id>	</item>
		<item>
		<title>setTimeout in Lightning Component [AURA]</title>
		<link>https://www.mhamzas.com/blog/2020/04/15/settimeout-in-lightning-component-aura/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=settimeout-in-lightning-component-aura</link>
					<comments>https://www.mhamzas.com/blog/2020/04/15/settimeout-in-lightning-component-aura/#respond</comments>
		
		<dc:creator><![CDATA[hamza]]></dc:creator>
		<pubDate>Tue, 14 Apr 2020 19:40:12 +0000</pubDate>
				<category><![CDATA[Salesforce]]></category>
		<category><![CDATA[aura]]></category>
		<category><![CDATA[js]]></category>
		<guid isPermaLink="false">https://www.mhamzas.com/?p=3086</guid>

					<description><![CDATA[I found it very important as many places, JS functions can save your a**. I mean LIFE. But specially setTimeout function when you need to perform some function after specific time. Here is an example to use JS setTimeout function in AURA <br /><a href="https://www.mhamzas.com/blog/2020/04/15/settimeout-in-lightning-component-aura/" class="more-link btn btn-primary">Read More</a>]]></description>
										<content:encoded><![CDATA[
<p>I found it very important as many places, JS functions can save your a**. I mean LIFE. But specially setTimeout function when you need to perform some function after specific time.</p>



<p>Here is an example to use JS setTimeout function in AURA Component,</p>



<p>1. If set timeout modifies any attributes, use $A.callback-</p>



<pre class="wp-block-code"><code>window.setTimeout(
     $A.getCallback(function() {
          helper.hideSpinner(component, helper)
     }), 500
);</code></pre>



<p>2. As per <a href="https://developer.mozilla.org/en-US/docs/Web/API/WindowOrWorkerGlobalScope/setTimeout" target="_blank" rel="noreferrer noopener">setTimeout documentation</a>, use any one of the following if calling function doesn&#8217;t modifies any attributes:</p>



<pre class="wp-block-code"><code>window.setTimeout(function(){ helper.hideSpinner(component, helper)}, 500);
// or
window.setTimeout(helper.hideSpinner, 500, component, helper);</code></pre>



<p>Sources, </p>



<p><a href="https://github.com/edelrabe/Salesforce-Recipes/wiki/setTimeout-in-Lightning-Component">https://github.com/edelrabe/Salesforce-Recipes/wiki/setTimeout-in-Lightning-Component</a><br><a href="https://salesforce.stackexchange.com/questions/206017/lightning-component-error-for-settimeout-bind-must-be-called-on-a-function/206018">https://salesforce.stackexchange.com/questions/206017/lightning-component-error-for-settimeout-bind-must-be-called-on-a-function/206018</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.mhamzas.com/blog/2020/04/15/settimeout-in-lightning-component-aura/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3086</post-id>	</item>
		<item>
		<title>Use Salesforce files (image file) on LWC, Aura or VF page as img tag</title>
		<link>https://www.mhamzas.com/blog/2020/01/09/use-salesforce-files-image-file-on-lwc-aura-or-vf-page-as-tag/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=use-salesforce-files-image-file-on-lwc-aura-or-vf-page-as-tag</link>
					<comments>https://www.mhamzas.com/blog/2020/01/09/use-salesforce-files-image-file-on-lwc-aura-or-vf-page-as-tag/#respond</comments>
		
		<dc:creator><![CDATA[hamza]]></dc:creator>
		<pubDate>Thu, 09 Jan 2020 14:13:57 +0000</pubDate>
				<category><![CDATA[Salesforce]]></category>
		<category><![CDATA[apex]]></category>
		<category><![CDATA[aura]]></category>
		<category><![CDATA[community]]></category>
		<category><![CDATA[files]]></category>
		<category><![CDATA[guest]]></category>
		<category><![CDATA[vf]]></category>
		<guid isPermaLink="false">https://www.mhamzas.com/?p=3058</guid>

					<description><![CDATA[Salesforce Files had been introduced with replacement of Attachment/Document object and with some great features like version controlling, sharing, preview and what not. We used to use Attachment/Document object for file hosting like images and pdf (specially on Classic). And if we <br /><a href="https://www.mhamzas.com/blog/2020/01/09/use-salesforce-files-image-file-on-lwc-aura-or-vf-page-as-tag/" class="more-link btn btn-primary">Read More</a>]]></description>
										<content:encoded><![CDATA[
<div class="wp-block-image"><figure class="aligncenter"><img data-recalc-dims="1" decoding="async" src="https://i0.wp.com/i.stack.imgur.com/p2i0t.png?w=640&#038;ssl=1" alt="enter image description here"/></figure></div>



<p>Salesforce Files had been introduced with replacement of Attachment/Document object and with some great features like version controlling, sharing, preview and what not.</p>



<p>We used to use Attachment/Document object for file hosting like images and pdf (specially on Classic).</p>



<p>And if we needed to use that image on any VF page or AURA component, we simply use record id and below code to generate url:</p>



<pre class="wp-block-code"><code>imageURL='/servlet/servlet.FileDownload?file=&lt;document_name>';</code></pre>



<p>But with Salesforce Files object, we have to maintain 3 records in 3 different objects &#8220;ContentDocument, ContentVersion, ContentLink&#8221; and for Public Link =&#8221;ContentDistribution&#8221;.</p>



<p>If you&#8217;re going to use your custom component/vf page internally, then you can use below code:</p>



<pre class="wp-block-code"><code>imageURL='/sfc/servlet.shepherd/document/download/&lt;YOUR FILE ID>';</code></pre>



<p>But when you need it to be visible for guest users, then you&#8217;ll need to generate PUBLIC URL which you can do manually.</p>



<h3 class="wp-block-heading">Generating Public Link: </h3>



<p>  Code below will generate public url automatically. You can use this code on a trigger on Files object</p>



<pre class="wp-block-code"><code>ContentDocumentLink cdl = [select contentdocument.id, contentdocument.title, contentdocument.filetype from contentdocumentlink where linkedentityid = '&lt;Opportunity Id>'];
ContentVersion cv = [select id from contentversion where contentdocumentid = :cdl.contentdocument.id];
ContentDistribution cd = new ContentDistribution();
cd.Name = 'Test';
cd.ContentVersionId = cv.id;
cd.PreferencesAllowViewInBrowser= true;
cd.PreferencesLinkLatestVersion=true;
cd.PreferencesNotifyOnVisit=false;
cd.PreferencesPasswordRequired=false;
cd.PreferencesAllowOriginalDownload= true;
insert cd;</code></pre>



<h3 class="wp-block-heading">&lt;img&gt; tag URL Generation</h3>



<p>Now the ContentDistribution object will store the public URL but it&#8217;ll contain the preview and we cannot use it as &lt;img src&gt; tag. Therefore we need actual image URL which you can get manually by properties of image and click &#8220;Copy image address&#8221;.</p>



<p>Below public link will be generated by code</p>



<pre class="wp-block-code"><code>https://&lt;domain>.my.salesforce.com/sfc/p/#q00000000sNA/a/q00000008a0b/6woo3x9YQNR7vTXR2oOOmknAOjpytHMEnZc2nGQ3F54</code></pre>



<p>Below correct link we need to use as &lt;img&gt; tag.</p>



<pre class="wp-block-code"><code>https://&lt;domain>--c.documentforce.com/sfc/dist/version/renditionDownload?rendition=ORIGINAL_Jpg&amp;versionId=068q0000000RAdv&amp;operationContext=DELIVERY&amp;contentId=05Tq0000001RiQf&amp;page=0&amp;d=/a/q00000008a0b/6woo3x9YQNR7vTXR2oOOmknAOjpytHMEnZc2nGQ3F54&amp;oid=&lt;organization Id>&amp;dpt=null&amp;viewId=</code></pre>



<p>Use following code to convert the public url to actual url we need.</p>



<pre class="wp-block-code"><code>List&lt;Domain> domainList = &#091;SELECT Domain FROM Domain];
                String domainString = domainList&#091;0].Domain;
                String domainNameSubstring = domainString.substringBefore('.');
                String secondPart = domainNameSubstring.substringBefore('-');
                String firstPart = domainNameSubstring.substringAfter('-');
                String customDomainName = 'https://' + firstPart + '--' + secondPart + '--c.documentforce.com';</code></pre>



<p>Happy coding!</p>



<p>Sources :<br> <a href="https://developer.salesforce.com/forums/?id=9060G0000005kE0QAI">https://developer.salesforce.com/forums/?id=9060G0000005kE0QAI</a> <br> <a href="https://salesforce.stackexchange.com/questions/236980/how-to-display-image-in-a-lightning-component">https://salesforce.stackexchange.com/questions/236980/how-to-display-image-in-a-lightning-component</a> <br> <a href="https://salesforce.stackexchange.com/questions/187424/display-image-which-is-stored-in-files">https://salesforce.stackexchange.com/questions/187424/display-image-which-is-stored-in-files</a> </p>



<p></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.mhamzas.com/blog/2020/01/09/use-salesforce-files-image-file-on-lwc-aura-or-vf-page-as-tag/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">3058</post-id>	</item>
	</channel>
</rss>
