Skip to main content

Posts

Showing posts from June, 2019

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

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.