Piyush
IndividualForum Replies Created
-
Hi Achintya,
Salesforce runs on a multi-tenancy environment and in order to have the same performance to the database, it has imposed some runtime limits called governor limits.
Governor limits are Salesforce's way of forcing you to write efficient, scalable code. The good: Governor limits prevent other orgs from writing bad code and taking up all the cloud CPU.
-
Piyush
MemberAugust 28, 2019 at 6:34 am in reply to: What is the difference between action and event in the salesforce lightning component ?Hi Nikita,
- Actions:-User interaction with an element on a component or app. User actions trigger events, but events aren’t always explicitly triggered by user actions. This type of action is not the same as a client-side JavaScript controller, which is sometimes known as a controller action. The following button is wired up to a browser onclick event in response to a button click.
- Events:-A notification by the browser regarding an action. Browser events are handled by client-side JavaScript controllers, as shown in the previous example. A browser event is not the same as a framework component event or application event, which you can create and fire in a JavaScript controller to communicate data between components. For example, you can wire up the click event of a checkbox to a client-side controller, which fires a component event to communicate relevant data to a parent component.
-
Piyush
MemberAugust 27, 2019 at 5:45 am in reply to: What is the best way to manage leads in Sales Cloud in Salesforce?Hi Achintya,
Best way to manage leads in salesforce:-
There are 7 Steps to manage leads in Sales Cloud in Salesforce:-
- Capture more leads
- Check whether you have duplicate lead records
- Follow lead qualification requirements
- Consider how to prioritize leads and distribute them among sales reps
- Keep your leads moving towards the conversion point
- Nurture your leads
- Track your lead management effectiveness
-
Piyush
MemberAugust 26, 2019 at 7:46 am in reply to: How to explain exception handling in Salesforce?Hi Sirichandan,
An exception denotes an error that disrupts the normal flow of code execution. You can use Apex built-in exceptions or create custom exceptions. All exceptions have common methods.
- AsyncException:- Any problem with an asynchronous operation, such as failing to enqueue an asynchronous call.
- JSONException:- Any problem with JSON serialization and deserialization operations. For more information, see the methods of System.JSON, System.JSONParser, andSystem.JSONGenerator.
- XmlException:- Any problem with the XmlStream classes, such as failing to read or write XML.
- EmailException:- Any problem with email, such as failure to deliver. For more information, see Outbound Email.
- InvalidParameterValueException:- An invalid parameter was supplied for a method or any problem with a URL used with Visualforce pages. For more information on Visualforce, see the Visualforce Developer's Guide.
- BigObjectException:- Any problem with big object records, such as connection timeouts during attempts to access or insert big object records.
-
Hi Deepak,
Yes, it possible to schedule an apex class. You have to choose weekly radio button from the frequency and select all the checkboxes(Sunday to Saturday):-
- Navigate to Setup, search for Apex in the Quick Find box, then select Apex Classes.
- Click Schedule Apex.
- Enter the job name, Example – Daily Account Update.
- Click the lookup button to search Apex class and select the class.
- Select Weekly for the frequency and select all the checkboxes.
- Select the start and end dates, and also the preferred start time.
- Click Save.
-
Piyush
MemberAugust 26, 2019 at 4:05 am in reply to: What is the difference between queueable methods and future methods in apex class in salesforce?Hi Deepak,
Future Method :-
- For avoiding Mixed_DML_Operations exception, we will be going for future method where it will be running in asynchronous mode when the system resource becomes available.
- If you want to perform complex DML operations and want to make external webservice @future(callout=true) means you can go for future method.
- Future method should be static and return type is void, parameters must be primitive types, sObjects are not accepted as future method parameters.
Queueable Apex :-
- It comes in handy , when you need to have both the operations of Batch and future method and it should implement Queueable Interface.
- If one job is dependent on other job means here we can chain the dependent job in execute method by system.enqueuejob(new secondJob());
- You can also able to chain upto 50 jobs and in developer edition you can able to chain upto 5 jobs only.
- It will accept non-primitive types like sObjects and it also runs in asynchronous mode.
- In this Queueable apex you can get Job Id to monitor the job progress.
-
Piyush
MemberAugust 23, 2019 at 3:59 am in reply to: How to execute Apex from Custom button or Javascript in salesforce ?HI Prachi,
We can call any apex method through JavaScript by following function:
sforce.apex.execute(“class_Name”,”Method_Name”,{Parameter_Name:Parameter_Value}); -
Piyush
MemberAugust 23, 2019 at 3:56 am in reply to: Which SOQL statement in salesforce that can be used to get all records?Hi Prachi,
Simply use the ALL ROWS clause.
SELECT Id, isDeleted FROM <Oblectname> WHERE isDeleted = true All ROWS – This will only return the deleted rows.
SELECT Id, isDeleted FROM <Oblectname> WHERE isArchived = true All ROWS – This will only return the archived rows.
SELECT Id, isDeleted FROM <Oblectname> All ROWS – This will return the deleted records, archived records and records that are neither deleted nor archived (data set identical to the one returned by a SOQL not using ALL ROWS) as well.You can-not use ALL ROWS and FOR UPDATE together.
Thanks.
-
Piyush
MemberAugust 23, 2019 at 3:29 am in reply to: How can you update Salesforce record using Apex?Hi Prachi,
Using Dynamic Apex we can achieve this :
//Lets assume this is record Id
Id recId = ‘a0P9000000ESXcV’;
Schema.SObjectType token = recId.getSObjectType();
Sobject s = token.newSobject();
s.put(‘Id’,recId );
s.put(‘Name’, ‘om’);
update s; -
Piyush
MemberAugust 22, 2019 at 3:48 am in reply to: How can we use Datetime field as a criteria in SOQL Query in Salesforce?Hi Prachi,
We cannot use Datetime as condition in Where Clause in between single Quotes.
You can do something like this ,
WHERE CreatedDate > 2005-10-08T00:00:00Z
Or, you can also use Date Literals like
WHERE CreatedDate > YESTERDAY
-
Hi prachi,
If newly created records are equal to or less than 9000, then it will be indexed in 1 to 3 minutes. However if records are more than 9000, then servers perform bulk indexing at a lower priority, so processing might take longer.
-
Piyush
MemberAugust 22, 2019 at 3:39 am in reply to: What is the difference between “apex:dataTable” and “apex:pageBlockTable” components in Visualforce in Salesforce?Hi Prachi,
apex:pageBlockTable
1) uses salesforce styling
2) No need to specify the headers
3) mandatory attribute "value".apex:dataTable
1) Need to specify the headers
2) we can specify custom style classes.
3) No mandatory attribute "value" unlike in pageblockTable -
Piyush
MemberAugust 22, 2019 at 3:33 am in reply to: How to get the Recordtype Id using Dynamic Apex in salesforce?Hi Prachi,
Normally to get the RecordtypeId for any sObject we use SOQL and it will count against your limit. So below method will bypass the need of SOQL Query.
Map<String, Schema.SObjectType> m = Schema.getGlobalDescribe() ;
Schema.SObjectType s = m.get(‘API_Name_Of_SObject’) ;
Schema.DescribeSObjectResult cfrSchema = s.getDescribe() ;
Map<String,Schema.RecordTypeInfo> RecordTypeInfo = cfrSchema.getRecordTypeInfosByName();
Id rtId = RecordTypeInfo.get(‘Record Type Name’).getRecordTypeId(); -
Piyush
MemberAugust 22, 2019 at 3:30 am in reply to: How to get “https” link for Visualforce page in Salesforce?Hi Prachi,
Use this to get “https” link instead of “http” for Visualforce page using URLFOR() in Email Template:-
<a href='{!SUBSTITUTE(URLFOR('/apex/SomePage', null, [id=Some_Object__c.Id,retURL="/apex/SomeOtherPage"]),'http:','https:')}'>Go to SomePage here!</a>
-
Piyush
MemberAugust 22, 2019 at 3:26 am in reply to: How do we determine that user is in Sandbox or Production using Salesforce Apex?Hi Prachi,
You can check it with the following API call:-
SELECT Id, InstanceName, IsSandbox, Name, OrganizationType FROM Organization
-
Piyush
MemberAugust 21, 2019 at 3:47 am in reply to: Getting a ‘syntax error’ error message when attempting to use this formula in Salesforce?Hi Deepak,
Looks like you're just missing some closing parenthesis on your second to last line
NOT((OR(RecordType.Name != "Customer",RecordType.Name != "Customer 2"),
should be
NOT((OR(RecordType.Name != "Customer",RecordType.Name != "Customer 2"))),
to be syntactically correct.
-
A global picklist is a restricted picklist by nature. Only a Salesforce admin can add to or modify its values. Users can’t add unapproved values, even through the API.
From Setup, enter Picklist in the Quick Find box, then select Picklist Value Sets.
Next to Global Value Sets, click New.
Enter a label for the global value set. This name appears in Setup, and when users create a picklist based on this global value set.
To tell users what these values are for, enter a specific description of the global value set. This text appears on the Picklist Value Sets list page in Setup.
Enter the values, one per line.
Optionally choose to sort the values alphabetically or to use the first value in the list as the default value, or both. You can’t change these settings later.
If you select both options, Salesforce alphabetizes the entries and then sets the first alphabetized value as the default.
Click Save.Your global value set is ready to be used in custom picklist fields. You can reorder the values by clicking Reorder.
-
Piyush
MemberAugust 21, 2019 at 3:41 am in reply to: Is there any way to define more than 1 SOQL quires in a batchable class start method in Salesforce?Hi Deepak,
if you are want to query the same object type but with multiple different WHERE selection clauses, and you then want to just apply the same logic to them, this is a simple matter of appropriately parenthesizing and combining the clauses into a single WHERE.
For example, if your first query is looking for instances matching:
A__c = '123' AND B__c = 'xyz'
while your second query is looking for instance matching:
A__c = '987' AND (B__c = 'abc' OR C__c = 999)
then you can construct your query as:SELECT Id, ... FROM MyObject__c WHERE
(A__c = '123' AND B__c = 'xyz') OR
(A__c = '987' AND (B__c = 'abc' OR C__c = 999)) -
Piyush
MemberAugust 20, 2019 at 3:47 am in reply to: How can I find all the reports built from a report type in Salesforce?While creating report type you found 'Store in Category' picklist Option, in that you specified some folder..check that folder then you can get all the reports..
-
Piyush
MemberAugust 20, 2019 at 3:45 am in reply to: What is the sequence of event propagation in Salesforce?The event propagation mode determines in which order the elements receive theevent. With bubbling, the event is first captured and handled by the innermost element and then propagated to outer elements. With capturing, the event is first captured by the outermost element and propagated to the inner elements.
Sequence of event propagation is:-
- Event capturing
- Event bubbling
-
Piyush
MemberAugust 20, 2019 at 3:40 am in reply to: What is force:hasRecordId in Salesforce Lightning Components?Hi Nikita,
force:hasRecordId interface is a Lightning component which enable the component to be assigned the ID of the current record. The current record ID is useful if the component is used on a Lightning record page, as an object-specific custom action or action override in Lightning Experience or the Salesforce app, and so on.
If your component implements force:hasRecordId, you don’t need to add a recordId attribute to the component yourself. If you do add it, don’t change the access level or type of the attribute or the component will cause a runtime error.
The recordId attribute is set only when you place or invoke the component in an explicit record context. For example, when you place the component directly on a record page layout, or invoke it as an object-specific action from a record page or object home. In all other cases, such as when you invoke the component as a global action, or create the component programmatically inside another component, recordId isn’t set, and your component shouldn’t depend on it.
-
Piyush
MemberAugust 19, 2019 at 6:05 am in reply to: What is the difference between insert() and database.insert() in Salesforce?Insert:
- A partial insert is not supported.
- Rollback is not supported.
- If we use the DML statement (Insert) in bulk operation, then if an error occurs the execution will stop. In that case, Apex code throws an error and none of the records will insert to the database.
Database.Insert:
- Database methods are static methods available in Database class.
- A partial insert is supported.
- Rollback is supported.
- Includes the optional all-or-none parameters that default true.
- If we use DML database methods (Database.Insert) in bulk operation, then if an error occurs the remaining records will be inserted/updated means partial DML operation will be done. The only record throwing an error will not be inserted/updated.
-
Piyush
MemberAugust 19, 2019 at 6:00 am in reply to: What is the use of setAbortable() in lightning Component?A component is automatically destroyed and marked invalid by the framework when it is unrendered. Mark a server-side action as abortable by using the setAbortable() method on the Action object in JavaScript.
An abortable action is sent to the server and executed normally unless the component that created the action is invalid before the action is sent to the server.
example:-
var action = cmp.get("c.serverEcho");
action.setAbortable(); -
Piyush
MemberAugust 19, 2019 at 5:53 am in reply to: What is the use of Salesforce lightning dualbox in sfdc?A lightning:dualListbox component represents two side-by-side listboxes. Select one or more options in the list on the left. Move selected options to the list on the right. The order of the selected options is maintained and you can reorder options.
I am sharing an example of lightning dualbox :-
<aura:application extends=”force:slds”> <!– search term –> <aura:attribute name=”term” type=”String” /> <!– currently displayed items –> <aura:attribute name=”options” type=”List” default=”[]” /> <!– all items –> <aura:attribute name=”allOptions” type=”List” default=”[]” /> <!– selected values –> <aura:attribute name=”selected” type=”List” default=”[]” /> <!– load data from somewhere –> <aura:handler name=”init” value=”{!this}” action=”{!c.init}” /> <!– update list when term changes –> <aura:handler name=”change” value=”{!v.term}” action=”{!c.search}” /> <lightning:input type=”text” value=”{!v.term}” label=”Filter” /> <lightning:dualListbox value=”{!v.selected}” options=”{!v.options}” label=”Items” sourceLabel=”Available” selectedLabel=”Selected” /> </aura:application>
({ init: function(component, event, helper) { // Load data helper.init(component); }, search: function(component, event, helper) { // Filter list helper.search(component); } })
({ init: function(component) { // Load some default values. component.set(“v.allOptions”, [ { value: “Hello”, label: “Hello” }, { value: “World”, label: “World” }, { value: “Test”, label: “Test” } ]); // Initialize the options list this.search(component); }, search: function(component) { // Search term var term = component.get(“v.term”); // Show all when no filter, or when filter matches label or value component.set(“v.options”, component.get(“v.allOptions”) .filter( item => !term || item.value.match(term) || item.label.match(term))); } })
-
Piyush
MemberAugust 14, 2019 at 2:35 am in reply to: Lightning properties are not working in visualforce page by removing the “force;slds”?Hi Deepak,
You need to include the Lightning CSS, which is not provided by apex:includeLightning (this provides only the JavaScript file). Instead, you need to also use apex:slds, which will bring in the SLDS CSS. By having these two elements separated, it allows you to use Lightning components without being forced into SLDS, and you can use SLDS without needing to write a component (e.g. if you wanted SLDS-looking Visualforce, or Angular, or something else).