Skip to main content

Posts

Showing posts from 2019

Filter any report by current Logged In User in Salesforce | Salesforce Tutorials | Salesforce Development

Upload Leads with Lead Assignment Rule in Salesforce ?

How to upload Leads with Assignment Rule in Salesforce ?
Let's take a scenario where you have to upload a large number of leads data in production/sandbox.
The first thing that comes in a salesforce developers mind will be to use Data Loader. Which will works absolutely fine in terms of Import/Export data.
Now suppose if you have an Lead Assignment Rule in your org and you wish to upload the leads with that assignment rule.
Is it still possible with Data Loader ?
Yes it is possible with data loader, we can add the assignment rule id in data loader settings.

Now when you run the insert, update or upsert, the assignment rule that you entered will be considered and fired for any record meeting the criteria of the assignment rule.
You can also use Data Import Wizard to assign the rule to leads.

While using data import wizard, there is a option to select lead assignment rule using which you could select the desire assignment rule before uploading the leads.
Please check below image for your ref…

Set selected value dynamically in Picklist/lightning:select in lightning component.

How to set selected value dynamically in lightning select in salesforce lightning component ? If you are developing something in lightning component then you must have face the situation to store selected value in your picklist.
Sometimes it works directly by setting the value in your lightning select. But if you are using a dynamic list and Key Value pair with an iteration to set the values, in that case setting value directly will not work.
We have to do some extra efforts with setting the value from controller. 
Please check the example below : 
In this example I am having a picklist of months and I want to change the selected value dynamically.
Component

1 2 3 4 5<lightning:select value="{!v.selectedMonth}" aura:id="selectMonth" label="Select Month" onchange="{!c.changeMonth}"><aura:iteration items="{!v.picklistValues}"var="item" indexVar="index"><option value="{!item.key}">{!item.valu…

Enforce FLS & CRUD in Lightning Component Manually.

How to Enforce CRUD & FLS in Lightning Component Manually ?
If you are a lightning component developer so you might already know that aura component does not support automatically CRUD & FLS in an apex controller.
This means the framework continues to display the records & fields for which user does not have CRUD access and FLS visibility.
For this we have to enforce the CRUD & FLS manually.
To get this done first you need to include with sharing keyword in your class name as shown below :


1 2 3publicwith sharing class myController{ }

After that we have to ensure in our apex controller that user see only those records on which he has access. We could check this using following functions :

isAccessible()isCreateable()isDeletable()isUpdateable()In below example I have used these function to check FLS manually : 


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38@AuraEnabled publicstaticBoolean isFLS(){��…

How to get Record Type ID without SOQL in Salesforce Apex ?

How to get Record Type ID without SOQL in Salesforce Apex ? To get record type id without SOQL you could use following code : 

Id RecordTypeId = Schema.SObjectType.YOUROBJECT.getRecordTypeInfosByName().get('RECORDTYPENAME').getRecordTypeId();
Using this line of code in apex you will be getting the record id of a Record Type Name.

Share this blog with your friends if this post helps you somehow.


How to Pass Javascript parameters to Apex in Salesforce ?

How to Pass Javascript parameters to Apex in Salesforce ?
To pass javascript parameters in apex you could use following code below :


1 2 3 4 5 6 7 8 9 10 11<apex:pagecontroller="passParam"><apex:form><script>function passParam() { document.getElementById("{!$Component.jsValue}").value ="I am from Javascript"; } </script><apex:inputHiddenid="jsValue"value="{!getValue}"/></apex:form></apex:page>
You can call this function on button's click to get value in your apex inputs.

Share this post with your friends if this help you somehow.


How to run JavaScript on render of a panel in Salesforce ?

How to trigger JavaScript on render of a panel in salesforce visualforce page ?
If you are a salesforce developer and using Javascript also in your visualforce page then sometimes you might need to trigger your JavaScript function on some events. 
In this article I will explain you to trigger your JavaScript function on Rendered of a output panel.
To this first write your Javascript function like for example here is my javascript function below : 


1 2 3function testMe(){ alert('I am working'); }




As you know that you can use this javascript in head tag and call it in button's click. But what if you need to call it when a panel is rendered.
For this just copy your javascript code before closing tag of that panel as shown below : 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15<apex:outputPanelrendered="{!renderMe}"><h3class="register-heading">Heading</h3><br/><p> Testing text������������…

Get parent id on related list new button's click. Salesforce lightning component

Get parent id on related list new button's click.Salesforce lightning component.



In this post I will explain how to get parent id from a related list New Button click.
If you are working on an object which is accessible from another object's related list so you might have a situation to get the Parent record id while creating a record from related list.
Here is code below to get parent id from url.

helper.js
getParameterByName: function(component, event, name) {         name = name.replace(/[\[\]]/g, "\\$&");         var url = window.location.href;         var regex = new RegExp("[?&]" + name + "(=1\.([^&#]*)|&|#|$)");         var results = regex.exec(url);         if (!results) return null;         if (!results[2]) return '';         return decodeURIComponent(results[2].replace(/\+/g, " "));     }
controller.js
var value = helper.getParameterByName(component , event, 'inContextOfRef');


Share this blog with your frie…

How to Clone related Files in Salesforce

How to clone related Files of an object in Salesforce ?

In salesforce while you are cloning or deep cloning an object you might need to clone related files also of that object.
Files are saved in ContentDocumentLink object in salesforce. You could google the fields of this object for reference.
You can not clone this object directly it will throw an error like "LinkedEntityId is not writable"
To solve this issue we have to clone files one by one and than insert new LinkedEntityId in it to link this with your object.
Here is code below :

List con = [SELECT ContentDocumentId,ContentDocument.Title, ContentDocument.ContentModifiedDate, ContentDocument.ContentSize FROM ContentDocumentLink WHERE LinkedEntityId=:recordId]; List conClone = new List(); for(ContentDocumentLink file: con){ ContentDocumentLink newclnk = file.clone(); newclnk.LinkedEntityId = YOUROBJECTID; newclnk…

Navigate from one component to another with variabls

How to Navigate from one component to another ?
If you are working in lightning component than you must have face this situation while you have to navigate to another component on button's click or after any event. 
If yes, so here are few line of code to get this done.


var evt = $A.get("e.force:navigateToComponent"); evt.setParams({ componentDef : "c:YOURCOMPONENTNAME", componentAttributes: { VariableName: Value } }); evt.fire(); Share this post with you friends if this help you somehow.

Alert in Lightning Component

How to show Alerts in Lightning Component. So today we'll learn to use alerts in lightning component. In lightning component we have multiple alerts.
1.  Info Alerts



To use info alerts copy and paste below code in your component.
<divclass="slds-notify slds-notify_alert slds-theme_alert-texture slds-theme_info"role="alert"><spanclass="slds-assistive-text">info</span><spanclass="slds-icon_container slds-icon-utility-user slds-m-right_x-small"title="Description of icon when needed"><svgclass="slds-icon slds-icon_x-small"aria-hidden="true"><usexlink:href="/assets/icons/utility-sprite/svg/symbols.svg#user"></use></svg>