Deepak
IndividualForum Replies Created
-
Deepak
MemberAugust 30, 2019 at 12:19 pm in reply to: Explain the syntax for writing a CRON expression in Salesforce Schedule job?CRON is a software utility that is a time-based job scheduler in Unix-like computer operating systems. Developers who want to set up and maintain software environments, use this cron to schedule jobs (commands or shell scripts) to run periodically at fixed times, dates, or intervals.
A CRON expression is basically a string of five or six fields separated by white spaces that represents a set of times, normally as a schedule to execute some routine.
Use schedule with an Apex class that implements the Schedulable interface to schedule the class to run at the time specified by a Cron expression.
System.Schedule(JobName, CronExpression, SchedulableClass);
The System.Schedule method takes three arguments: a name for the job, an expression used to represent the time and date the job is scheduled to run, and the name of the class.
Sample Code
TestSchedulableClass testobj = new TestSchedulableClass();
String cronexpression = ‘0 0 0 ? * * *’
System.schedule(‘Testing’, cronexpression, testobj);
The Above Code Executes TestSchedulableClass At 12:00 AM Every Day .
CRON expression has the following syntax:
0 0 5 ? * 1,2,3,4,5,6,7
{1} {2} {3} {4} {5} {6}
{1} Seconds – so 0 here i.e. start of the minute.
{2} Minutes – 0 again so start of the hour.
{3} Hours – 5 so 5 am. Uses 24 hour notation so 21 = 9pm
{4} Day_of_month – ? means no specific value, only available for day of the month and day of the week.
{5} Month – * indicates all values, i.e. every month. (if we only want to run on 1st Jan say, this would be 1)
{6} Day_of_week – 1,2,3,4,5,6,7 here specifies days 1,2,3,4,5,6,7 in the week. We could also write this string as MON-FRI or preferably as * to indicate all values.
So this job reads to run at “0 seconds past 0 minutes of the 5th hour on no specified day of the month for every month of the year for every day of the week”.
-
Deepak
MemberAugust 30, 2019 at 12:06 pm in reply to: How can I filter logs which are captured by using system.debug() method in Salesforce?Select the debug only options in logs that will show your output of debug used. If still you are not getting result enter debug variable used in filter.
-
Deepak
MemberAugust 30, 2019 at 11:59 am in reply to: Which annotation is used to call the method by process builder in Salesforce?In actions section of process builder, we can execute apex method as well. This is the main advantage of process builder as we cannot execute the apex class using flows or workflows. To call an Apex method, add the Call Apex action to yourprocess and select an Apex class with an invocable method.
-
Deepak
MemberAugust 29, 2019 at 12:46 pm in reply to: What is the use of rowcause in the Apex Managed Sharing in Salesforce?In the Salesforce user interface, the Reason field on a custom object specifies the type of sharing used for a record. This field is called rowCause in Apex or the API. Each of the following list items is a type of sharing used for records. The tables show Reason field value, and the related rowCause value.
-
Deepak
MemberAugust 29, 2019 at 12:05 pm in reply to: Differentiate between Schema.FieldSet and Schema.FieldSetMember in Salesforce?Schema.FieldSet
You can use dynamic bindings to display field sets on your Visualforce pages. A field set is a grouping of fields. For example, you could have a field set that contains fields describing a user's first name, middle name, last name, and business title. If the page is added to a managed package, administrators can add, remove, or reorder fields in a field set to modify the fields presented on the Visualforce page without modifying any code. Field sets are available for Visualforce pages on API version 21.0 or above. You can have up to 50 field sets referenced on a single page. A Salesforce org can have up to 500 field sets.
Schema.FieldSetMember
Contains methods for accessing the metadata for field set member fields
Use the methods in the Schema.FieldSetMember class to get details about fields contained within a field set, such as the field label, type, a dynamic SOQL-ready field path, and so on. The following example shows how to get a collection of field set member describe result objects for a specific field set on an sObject:
List<Schema.FieldSetMember> fields =
Schema.SObjectType.Account.fieldSets.getMap().get('field_set_name').getFields(); -
Deepak
MemberAugust 29, 2019 at 11:58 am in reply to: what is the use of wrapper class in Salesforce?A wrapper or container class is a class, a data structure, or an abstract data type which contains different objects or collection of objects as its members. A wrapper class is a custom object defined by programmer wherein he defines the wrapper class properties.
-
Deepak
MemberAugust 28, 2019 at 12:00 pm in reply to: what is the use of $A.getCallback() in Salesforce lightning component ?Use $A.getCallback() to wrap any code that modifies a component outside the normal rerendering lifecycle, such as in a setTimeout() call. The $A.getCallback() call ensures that the framework rerenders the modified component and processes any enqueued actions.
-
Deepak
MemberAugust 28, 2019 at 5:57 am in reply to: Explain the rules for automation in Salesforce?Automation rules are definitely the heavy lifters in the automation tools toolbox. They’re both powerful and flexible, which makes them a popular choice when automating. They’re also the most comprehensive automation tool offered by Pardot. But as the old saying goes, “When you have a hammer, everything looks like a nail.” We look at what automation rules do and why you use one, so you can make smart decisions about when to use your “hammer.”
Automation rules allow you to perform certain marketing and sales actions based on criteria that they specify. Automation rules continuously look for prospects who match the rule criteria. They are retroactive; but any changes after the rule becomes live are not.
A few things to note about automation rules:
Automation rules also begin in the “paused” status. This allows the user to preview matches before resuming the rules for the actions to take place.
You can set automation rules to repeat if you select the repeat rule checkbox. This option lets you control how many times the rule can match a prospect.If you leave repeat rule unchecked and an existing automation rule is updated, the automation rule does not match already matched prospects for the same rule.
Deleting an automation rule stops it from running, but the actions it has already applied to prospects is not undone. An automation rule resumes if the rule is ever restored from the recycle bin and restarted. -
Approval process in Salesforce is an automotive process which approves records for salesforce. As the process is automotive it works on certain criteria. The approval process may include rejection, recalled or first time submission of approval.
This automated process is handled using steps defined by the developer. It may be single step approval or for more secure it can be multi-steps approval.
Common steps for approval in salesforce are:
Setup -> Create -> Workflow and Approval -> Approval Process
Select object for approval process to be written
Click on Create New Approval Process
Select Standard Setup Wizard from drop down
Enter the Process name, Unique Name and description for your process
Specify Entry criteria- This reply was modified 5 years, 3 months ago by Deepak.
-
You’ve customized the Activity Type picklist field and built two great new reports to help figure out the kinds of activities that win deals. Now it’s time to actually get these updates into the hands of your sales team. As with all important updates like this, it’s critical to develop deployment and communication plans to get your sales reps and managers ready.
Introduce Picklist Updates
In the previous unit, we customized the Type field on the Activity object with new values. When you initially deploy the new values in your production org, there won’t be any activities with the new values. It takes time for sales reps to generate activity records with your new options. Decide how best to educate your sales team on the updated picklist options.Are your sales reps already logging activities? If so, work with sales management to let reps know about the new values in the picklist. A brief email or Chatter post from a sales leader is a good way to get users up to speed on the new picklist choices.
If your sales reps aren’t already logging activities, then come up with a comprehensive communication and enablement plan. Consider hosting some enablement sessions for your sales users to explain how to track activity in Salesforce—and the benefits. Encourage sales reps to get hands-on experience via Trailhead (see our resources section to find great modules that dig into sales productivity features for both admins and sales users).
Analyze Key Sales Activities
Once your new picklist values are live, you can deploy the new reports and dashboards. Make sure to adjust the time range or other filters on the reports if needed to fit your business. If you have a large sales team, consider additional filters for certain user roles or sales territories. You can also apply a filter on the dashboard that gives managers and users a big-picture view with the option to drill down into their particular team.Let’s look at our example dashboard from the prior unit.
Looking at the win rates, two sales reps have the highest win rates—Cindy Central and Kasey Central. Look for patterns in their activity breakdown on the right—both Cindy and Kasey have logged site visits, and Cindy logs demos. Other sales reps aren’t logging any activities. The central team appears to have landed on some approaches that work. These kinds of insights serve as a great blueprint for other sales teams.
After your sales team logs activities for a month or two, analyze the patterns, and see if any indicators of success emerge. Determining which activities lead to new deals is of great interest to most sales reps. Wouldn’t it be great if everyone had a higher win rate?
Monitor Usage
Congratulations! Your sales team now has some great new methods to sell smarter and win more deals. As with any new feature, it’s important to monitor usage, collect feedback, and make improvements based on that data. Here are a few things you can do to ensure the success of this new functionality.Check adoption of the new Type picklist values: Periodically review the Key Activities Report. Are users employing the new picklist values? If not, determine why. Are users not logging any activities?
Report on reports: What better way to track Salesforce report usage than with another Salesforce report? Now that you’re an expert on building reports, go ahead and create one to track how new key activity and win rate reports are used. Use the Last Run Date field to see if sales users are using the reports you created.
Review the value of reports: Plan to review the Key Activities Report and dashboard components quarterly with sales management to ensure they’re still useful. If not, determine where updates are needed.
Remind users: Share any insights you found when analyzing your Key Activities Report. If interesting patterns emerge, make sure to make those findings public. Get with sales leaders every week and choose which numbers and success stories you want to share with the sales organization via email and Chatter. -
S-controls provide a flexible, open means of extending the Salesforce user interface, including the ability to create and display your own custom data forms. But, Visualforce pages supersede s-controls. Organizations that haven't previously useds-controls can't create them
-
API stand for Application programming interface.It is protocol thorugh which one application communicate with other. Salesforce can integrate with third party application and communicate data with API.
-
Deepak
MemberAugust 26, 2019 at 12:09 pm in reply to: What is the use of Blob Variable in Salesforce?Blob is a collection of binary data stored as a single object. You can convert this data type to String or from String using the toString and valueOf methods, respectively. Blobs can be accepted as Web service arguments, stored in a document (the body of a document is a Blob), or sent as attachments.
Blob Methods
The following are methods for Blob.
size()
Returns the number of characters in the Blob.
toPdf(stringToConvert)
Creates a binary object out of the given string, encoding it as a PDF file.
toString()
Casts the Blob into a String.
valueOf(stringToBlob)
Casts the specified String to a Blob. -
Deepak
MemberAugust 26, 2019 at 11:43 am in reply to: Which tag is used for password protection in Salesforce?<apex:inputsecret> :-
apex:inputsecret tag is used to display any input values in the form dot’s like passwords. Inputfield values are displayed as (………..). This apex:inputsecret tag is used when creating submit form where password fields are required.
Tag Example :-<apex:inputsecret value=”{!inputValue}” id=”theSecretInput”>.
-
Deepak
MemberAugust 26, 2019 at 11:40 am in reply to: What is the Purpose of Contain Method in Salesforce?contains(substring)
Returns true if and only if the String that called the method contains the specified sequence of characters in substring.for example
String myString1 = 'abcde';
String myString2 = 'abcd';
Boolean result =
myString1.contains(myString2);
System.assertEquals(result, true); -
Force:refreshView is an event that can be used to refresh the view. To elaborate, consider a scenario where you have a custom component on the Account detail page and this component consists of a form that updates a field on the account.
-
Google Analytics integrates with your self-service community to track user types, user IDs, pageviews on Salesforce objects, and customer search activity. ... Create custom dimensions in your Google Analytics account that capture user type and Salesforce object information.
-
Deepak
MemberAugust 23, 2019 at 9:35 am in reply to: How to query and abort scheduled job using Apex in Salesforce?I have a schedule class named schedGroupAccounts and I scheduled it for every 15 minutes via the execute anonymous in the developer console.
Code Snippet for Scheduling apex class
System.schedule('Scheduled Job 1','0 15 * * * ?',new schedGroupAccounts());
To monitor your apex jobs, go to Setup -> Monitor -> Jobs -> Apex Jobs.So you scheduled it, now you want to abort the job for some reason. How can you do? The jobs we schedule will be available in the crontrigger object. Lets query the trigger and see how we can retrieve the particular job to abort it.
SELECT CreatedById, CreatedDate, CronExpression, CronJobDetailId, EndTime,Id, LastModifiedById, NextFireTime, OwnerId, PreviousFireTime, StartTime, State, TimesTriggered FROM CronTrigger
So from the above query, I found my job based on the cronexpression and createddate. I want to abort that job. So I get the id of the job and assign it to the soql query.CronTrigger ct = [SELECT Id FROM CronTrigger where Id=''];
System.abortJob(ct.Id); -
Deepak
MemberAugust 22, 2019 at 12:52 pm in reply to: What is the difference between controller and extension in visualforce pages in salesforce ?In the context of visualforce, to take advantage of the built-in features of Visualforce to access your org's data, you must use a controller. All controllers are Apex classes, either standard Apex classes (ApexPages.StandardController or ApexPages.StandardSetController) or your own custom Apex class. You can also extend functionality of any of these with an Extension class.
I tend to be a bit picky with my terminology here. Controllers are controllers. Extensions are not controllers. And for me, the difference is that extensions cannot live by themselves on a page. In other words, I'm not permitted to use extensions, unless my page has a controller in the first place.
Another distinguishing feature is that a page is allowed only one controller ever. But I can add as many extensions as I need.
So let me begin (what has become a dissertation) with controllers:
Controllers are attached to your page using one of three mutually exclusive formats, standard controller, standard list/set controller, custom controller.
For a page with a single record, accessing standard data and behavior of your object you would use standard controller:
<apex:page standardController="Account"...> ... </apex:page>
If you want a page with many records, using standard list view, and list actions you could use standard list controller:<apex:page standardController="Account" recordsetVar="accountsList"...> ... </apex:page>
If you want to use completely custom functionality and don't really need most of the standard object behaviors, custom controller is a good option, but bear in mind, any standard actions you want to use will have to be implemented in your custom class. A page with a custom controller would use the following attribute:<apex:page controller="MyApexClass"...> ... </apex:page>
But bear in mind, you yourself can instantiate ApexPages.StandardController to use its features and functionality. I often use the pattern below to instantiate standard controller to get access to its methods:public with sharing class MyApexClass {
private ApexPages.StandardController ctrl;
public Account acct {get;set;}
public MyApexClass(){
try{
acct = [select Name from Account
where Id = : ApexPages.currentPage().getParameters().get('id')];
} catch (QueryException e) {
acct = new Account();
}
ctrl = new ApexPages.StandardController(acct);
}
public PageReference save(){
//here I can put additional functionality or just leave it as-is.
return ctrl.save();
}
}
The above instantiates Standard Controller privately, but then surfaces a public save method that is just a pass-through of the controller's save method. The constructor does the housekeeping of creating the actual record I'm working with.If I want to add to the functionality of any controller, I can then use an extension. Extensions work with either standard or custom controllers. Standard controller with custom extension, for me, is the most common construct I use for Visualforce that will operate inside my org. I get all the power of the standard controller, but all the flexibility of Apex. The syntax for an extension with a standard controller page would be as follows:
<apex:page standardController="account" extensions="MyExtClass"...> ... </apex:page>
The extension class is then required to implement a constructor that accepts the type of the controller. You will then typically want to get a handle to the standard controller instance that is floating around, and the sObject instance that it represents. So for a standard controller page:public with sharing class MyExtClass {
private ApexPages.StandardController ctrl;
public Account acct {get;set;}
public MyExtClass(ApexPages.StandardController controllerParam){
ctrl = controllerParam;
acct = (Account) ctrl.getRecord();
}
public PageReference customsave(){
//here I override my standard save functionality before I return the save call.
return ctrl.save();
}
}
With a custom controller and extension, you can probably extrapolate from the above, but just to close the loop.<apex:page controller="MyApexClass" extensions="MyExtClass"...> ... </apex:page>
Again, the extension class implements a constructor that accepts the type of the controller, only now it is my custom class. From there, apart from getting a local handle to your custom controller instance, there isn't a pattern, per-se, but the local handle allows you to interact directly with your custom controller, in whatever way necessary, of course. :public with sharing class MyExtClass {
private MyApexClass ctrl;
public MyExtClass(MyApexClass controllerParam){
ctrl = controllerParam;
}
} -
Deepak
MemberAugust 22, 2019 at 12:48 pm in reply to: What is the Use of Aura:method tag in Salesforce?In our last post we talk about Lightning Component Event for Component communication. In this post we will talk about how to do component communication with the help of <aura:method > . Aura:Method enables you to directly call a method in a component’s client-side controller instead of firing / handling a component event. With the help of <aura:method > we can call child component method from parent component.
Syntax :-
How to call method :- Simply call the function and pass parameter value in parent component
component.sampleMethod(arg1);
How to declare method :- Declare the aura:method with attribute
<aura:method name="sampleMethod" action="{!c.callAction}" description="Sample">
<aura:attribute name="param1" type="String" default="param1"/>
</aura:method>Aura Method Action :- get the Aura:Attribute value with event.getParam('arguments');
({
callAction: function(cmp, event) {
var params = event.getParam('arguments');
if (params) {
var p1 = params.param1;
// add your code here
}
}
}) -
This interface is used to indicate that a component takes a record (SObject) as an attribute.
Add the force:hasRecordId interface to a Lightning component to 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. This interface has no effect except when used within Lightning Experience, the Salesforce mobile app, and template-based communities.
This interface is a marker interface. A marker interface is a signal to the component’s container to add the interface’s behavior to the component. You don’t need to implement any specific methods or attributes in your component, you simply add the interface name to the component’s implements attribute.
The force:hasRecordId interface does two things to a component that implements it.
It adds an attribute named recordId to your component. This attribute is of type String, and its value is an 18-character Salesforce record ID, for example: 001xx000003DGSWAA4. If you added it yourself, the attribute definition would look like the following markup:<aura:attribute name="recordId" type="String" />
Note 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.
When your component is invoked in a record context in Lightning Experience or the Salesforce app, the recordId is set to the ID of the record being viewed.
Important 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.These unsupported contexts include a few contexts that might seem like they should have access to the current record. Examples of these other contexts include the following:Invoking the component from a global action (even when you’re on a record page)
Invoking the component from header or footer navigation in a community (even if the page shows a record)
force:hasRecordId and force:hasSObjectName are unsupported in these contexts. While the marker interfaces still add the relevant attribute to the component, accessing either attribute generally returns nullor undefined. -
Deepak
MemberAugust 21, 2019 at 11:54 am in reply to: What is the use of $A.enqueue Action(action) in Salesforce Lightning Component?It adds the server-side controller action to the queue of actions to be executed. Rather than sending a separate request for each individual action, the framework processes the event chain and batches the actions in the queue into one request. The actions are asynchronous and have callbacks
-
Deepak
MemberAugust 21, 2019 at 10:00 am in reply to: When are Data Validation Rules enforced in Salesforce?If you’re a Salesforce administrator, one of your main concerns is data integrity. But for a typical user, a high standard of data entry is probably low on the priority list.
Salesforce has many tools to help you enforce data standards, including validation rules, which verify that the data entered in a record matches standards you specify. If the record lacks necessary data, the user will see an error message and will not be allowed to save the record until the data meets the standards.
Let’s walk through building a validation rule, using an actual example from the Newfangled org.
When a sales user marks an opportunity as “Closed Unqualified,” we have a custom field called “Unqualified – Reason” to collect the reason that opportunity was unqualified. We want that custom field to be required, but only if the opportunity is set to “Closed Unqualified.” We can accomplish this by adding a validation rule.
First, navigate to the menu for the object you’re interested in. For this, I’m interested in Opportunities, so I navigate to Setup > Build > Customize > Opportunities > Validation Rules. I click “New” to start building my rule.
Enter a descriptive rule name and enter a description of what this rule is enforcing. Make sure the Active box is checked (assuming you’ll be using this rule right away).
The work of the validation rule is done by a formula expression that evaluates data from one or more fields and returns a value of True or False. If the formula evaluates to True, the user will see an error message.
You need to write a formula that describes the exact data entry condition you are trying to avoid. In this case, we need to describe an opportunity record with the “Stage” field set to “Closed Unqualified” and with no value in the “Unqualified – Reason” field.
Salesforce formulas may seem more than a little confusing. And they can be. But fear not! There are many, many online resources with sample formulas that are available for anyone to use. Salesforce has an entire index of sample validation rules, and the Salesforce Success Community is full of Salesforce users helping other users. Chances are good that you’ll find almost exactly the formula you need from an answer to another user’s query, or at least something close to use as a starting point. There’s absolutely no shame in copying and pasting a formula that someone else has written.
There are also a ton of Salesforce resources to help you become a pro at writing Salesforce formulas. Start with this overview of Salesforce formula operators and functions.
Below you can see how I’ve taken our field criteria (Stage = Close Unqualified, Unqualified Reason = blank) and translated that into a formula. If this formula evaluates to true (i.e., both of those field criteria are true), the record won’t save, and the user will see an error message.
The last step is to define your error message. You can enter whatever you want here, and then choose where the error message displays. You can either have it display at the top of the record or inline with a specific field.
Now that I’ve built my rule and made sure it’s active, I need to see if it works.
I’m going to set my opportunity to “Closed Unqualified” and purposefully leave “Unqualified – Reason” blank. Can I save my record?
-
Deepak
MemberAugust 21, 2019 at 9:34 am in reply to: What are the different ways of deployment in Salesforce?Once you are done with your development you need to migrate your code from your development organization to the organization where business user can use your code. So in this tutorial we will learn different types of organization and Salesforce Deployment Methods from one organization to another organization.
1. ORGANIZATION TYPE
Salesforce provides two types of organizationa) Production (This is Production where end user or business user use Salesforce System)
b) UAT Sandbox (UAT stands for User Acceptance Testing and this organization used by business user to do final testing before code move to Production Organization).
c) Developer Sandbox: This Sandbox is Used to Start Development.
2. DEPLOYMENT TYPE
There are 3 ways to deploy or migrate code from one organization to another organizationA) CHANGE SET
Change set is standard and point and click method do deploy code and migrate code. This is useful and recommended when you are new to Salesforce.B) ECLIPSE IDE
Eclipse IDE deployment is easy to use where you can migrate code with easy steps but this deployment method is recommended only if you have less number of test classes. If you have more than 100 classes eclipse generally hang and doesn’t show any progress.C) FORCE.COM ANT MIGRATION TOOL
Force.com Ant migration tool provides more control over deployment and developer find it very complex but the truth is it is not that much complex if step by step procedure followed.Step 1 : You need to install Java SDK
Step 2 : Download Ant from http://apache.mirrors.ionfish.org//ant/binaries/apache-ant-1.9.6-bin.zip
Step 3 : Extract Step 2 Zip file in C: directory. It will create a new directory called Apache-Ant. Setup Ant Home Path in your windows environment
Step 4 : Download Force.com Migration too
Step 5 : Copy ant-salesforce.jar from step 4 and copy this in Ant lib folder and Sample folder in Apache-ant folder from zip folder
Step 7 : Replace username and password in Step6 code with your username and password.
Step 8 : Create a new folder in Sample folder and name it as retrieveSource.
Step 9: Copy following code to create a package.xml file inside retriveSource folder, you can follow Force.com migration guide to generate and add more component in package.xml.
Step 8 : Open Command prompt and go to c:apache-antsample directory and type ant retrieve. It will create a new directory called retrieveMetadata.
Step 9 : To deploy to target organization type ant deploy. Your deployment will start and new code will be available in target organization.
-
Deepak
MemberAugust 21, 2019 at 9:28 am in reply to: What is a flow in salesforce ? what is the use of it ?Flow is an application inside the Salesforce that automates a business process by collecting data and performing operations in your org or an external system. Flow can fetch, delete, update and create records on multiple objects. Flows in Salesforce can be implemented in two ways
Screen Flows
Auto-launched FlowScreen Flows
In this type of flow, there will be a series of screen elements to gather information from the user and perform some operation. Screen flows can be accessed from custom buttons, custom links, Visualforce Pages etc. This type of flow is implemented if a user interaction is needed in the process.Auto-launched Flow
Auto-screenshot runs in the background without any user interaction. Auto-launched flows can be accessed from custom buttons, custom links, Visualforce Pages, process builder and Apex etc.Consider a business scenario, an organizationwith name ABC PVT LTD has Accounts Object. The requirement is that Opportunity for an Account should be created automatically when a button is clicked on Account object. This can be achieved by creating a flow and accessing the flow using a custom button. Now I’ll be showing you how to create a salesforce flow to meet the above requirement.