Pages

Monday, December 25, 2017

Salesforce: Schedule Action in Process Builder

You may read and see somewhere that Process Builder far superior to Workflow, but for some reason, you don't see the option to schedule action, while everyone says that you can schedule action using Process Builder.

There are even ideas in IdeaExchange asking for more details of the schedule jobs from process builder:
Scheduled actions from Process Builder should appear under Time-Based Workflow
Process Builder: Waiting Flow Interviews: Provide Better Information

But, where is the Schedule Action? Is this something need to be enabled by Salesforce support? Or my Salesforce edition does not support Process Builder? Process Builder available from Professional Edition and above, read here Lightning Process Builder.

only immediate action and no scheduled action option

scheduled action available to be configured

What is the causes in the 1st screenshot we don't see scheduled actions option? To have schedule actions, your process has to meet at least 1 of 2 criteria below:
  • Start the process only when a record is created (1). Select this option when you choose an object for your process, or
  • Start the process when a record is created or edited (2). In addition, select the advanced option to execute actions only when specified changes are made (3) when you add criteria to your process.



I have a blog written last year related to "Do you want to execute the actions only when specified changes are made to the record?", so here is the other usage of that checkbox, using ISNEW() and ISCHANGED() will not enabled scheduled action option.


Reference



Sunday, December 24, 2017

Salesforce Report: Bar Chart with Cumulative Line Chart

In Salesforce reporting (include Lightning), you can use a field only once, if you have admin right, you can create formulas field that returns the same value with the original one, so can use it too in the report.

We have a request to have a chart with opportunity amount in both monthly total and cumulative YTD. Salesforce report has the cumulative option for a line chart, but unfortunately, as mentioned in the first paragraph, we can't use a field more than once in a chart, while to create a formula field for this scenario of dynamic values seems like not possible. The easier option is to export the data and easily built it in Excel, but it would not be stored in the platform.


simple bar chart only shows the total monthly amount



change to line bar chart and enable the Cumulative option


add the new measurement, but only can select different field, in this case, I use Count, plot as line chart and as the second axis.


create new formula field Amount clone, but because the main chart is a bar chart, the Cumulative option is not available for the additional measurement.


Now, let's see how is the data looks like in the report for the last chart:


So, if we can get the cumulative value in the last column, instead of the same value, then we can achieve the report requested.
For row 1, it would be just that row itself.
For row 2, it would be row 2 amount + row 1 amount.
For row 3, it would be row 3 amount + row 2 amount + row 1 amount.

Remember, there is a function called PREVGROUPVAL() in the Custom Summary Formulas for the report. We can use this function for this need. This function calculates values relative to a peer grouping. If there’s no previous grouping, the function returns a null value.

This function returns the value of a specified previous grouping. A “previous” grouping is one that comes before the current grouping in the report. Choose the grouping level and increment. The increment is the number of columns or rows before the current summary. The default is 1; the maximum is 12. You can only use this function in custom summary formulas for reports.

This is the function pattern
PREVGROUPVAL(summary_field, grouping_level [, increment])
From here, see that you can adjust the incremental of previous grouping.

Adding Custom Summary Formula with PREVGROUPVAL() function allow us to get this table



Then we can easily add this chart to the report:



Step by step:
1. From your summary or matrix report, create Custom Summary Formula, in this example, I called it Cumulative Amount.

2. In "Where will this formula be displayed?", select "Grouping 1:".

3. Copy and paste following formula:
AMOUNT:SUM
+
IF(NOT ISBLANK(PREVGROUPVAL(AMOUNT:SUM, CLOSE_DATE,1)),
PREVGROUPVAL(AMOUNT:SUM, CLOSE_DATE,1), 0)
+
IF(NOT ISBLANK(PREVGROUPVAL(AMOUNT:SUM, CLOSE_DATE,2)),
PREVGROUPVAL(AMOUNT:SUM, CLOSE_DATE,2), 0)
+
IF(NOT ISBLANK(PREVGROUPVAL(AMOUNT:SUM, CLOSE_DATE,3)),
PREVGROUPVAL(AMOUNT:SUM, CLOSE_DATE,3), 0)
+
IF(NOT ISBLANK(PREVGROUPVAL(AMOUNT:SUM, CLOSE_DATE,4)),
PREVGROUPVAL(AMOUNT:SUM, CLOSE_DATE,4), 0)
+
IF(NOT ISBLANK(PREVGROUPVAL(AMOUNT:SUM, CLOSE_DATE,5)),
PREVGROUPVAL(AMOUNT:SUM, CLOSE_DATE,5), 0)
+
IF(NOT ISBLANK(PREVGROUPVAL(AMOUNT:SUM, CLOSE_DATE,6)),
PREVGROUPVAL(AMOUNT:SUM, CLOSE_DATE,6), 0)
+
IF(NOT ISBLANK(PREVGROUPVAL(AMOUNT:SUM, CLOSE_DATE,7)),
PREVGROUPVAL(AMOUNT:SUM, CLOSE_DATE,7), 0)
+
IF(NOT ISBLANK(PREVGROUPVAL(AMOUNT:SUM, CLOSE_DATE,8)),
PREVGROUPVAL(AMOUNT:SUM, CLOSE_DATE,8), 0)
+
IF(NOT ISBLANK(PREVGROUPVAL(AMOUNT:SUM, CLOSE_DATE,9)),
PREVGROUPVAL(AMOUNT:SUM, CLOSE_DATE,9), 0)
+
IF(NOT ISBLANK(PREVGROUPVAL(AMOUNT:SUM, CLOSE_DATE,10)),
PREVGROUPVAL(AMOUNT:SUM, CLOSE_DATE,10), 0)
+
IF(NOT ISBLANK(PREVGROUPVAL(AMOUNT:SUM, CLOSE_DATE,11)),
PREVGROUPVAL(AMOUNT:SUM, CLOSE_DATE,11), 0)


You can adjust the formula as necessary, change AMOUNT:SUM with RowCount if you need to show the number of records instead of Opportunity Amount.
Note: you can use this solution if your report has the maximum grouping of 13, because the maximum incremental for PREVGROUPVAL() is 12.

4. Add Vertical Bar Chart with Y-axis is the main amount, then add measure using Custom Summary Formula created in step 1-3, select Plot as Line Chart.



You also can enable "Plot on Second Axis" to get second Y-axis values for the line chart values.



Reference:



Tuesday, December 19, 2017

Salesforce: How to block Workbench?

Workbench is an unofficial, yet powerful tool for Salesforce admin and developer to perform almost anything related to Salesforce support. In many cases, end user supposed have no access to this tool, although it still honors user permissions assigned in Salesforce. However, can we block the normal users from accessing Workbench?

Yes, in the previous blog, we discussed how to turn off Salesforce1. Using the same method, we can block the normal user from accessing Salesforce from Workbench.

1. Connected Apps
Navigate to Setup | Apps | Connected Apps | Manage Connected Apps, click Edit link on Workbench.
Change the 'Permitted Users' value under 'OAuth policies' to 'Admin approved users are pre-authorized', and click Save.


2. To Give Access
Now, you want specific users able to access Workbench. There are 2 options:

a. Using Profile
All users in the profile will be able to access Workbench.
In the Workbench page under Connected Apps, scroll down to Profiles, click Manage Profiles button. Select all profiles that need to access Workbench, then click Save button.

b. Using Permission Set
Using Permission Set is more flexible, only users assigned with that permission set will be able to access Workbench.
But before configure in Connected Apps, you need to create a permission set without any permissions, then assign users to that Permission Set. Next, in the Workbench page under Connected Apps, scroll down to Permission Sets, click Manage Permission Sets button. Select all permission sets that need to access Workbench, then click Save button.


When a user without permission to access Workbench, the user will see an error message when try to login to Workbench OAUTH_APP_ACCESS_DENIED: user is not admin approved to access this app.




Monday, December 18, 2017

Salesforce Lightning App page not refresh

My experience when configuring Salesforce Lightning App page that related to UI (user interface) is not great, when I add a field in the page layout or adding components into Lightning App, it doesn't reflect immediately when I open a record. In many times, I need to refresh many times, even have to logout and login back. This experience never happens in Classic.

Is this a bug with Lightning Experience? Further checking this issue, I found this basically related to caching that implemented for Lightning Experience.

There is a setting under Setup | Session Settings called Enable secure and persistent browser caching to improve performance.


Once this caching disabled, I do not have that experience/issue anymore. Since this caching will improve user experience overall, so I do not suggest to disable in production, but only in Sandbox when you need to configure the user interface a lot.

From Salesforce documentation, enables secure data caching in the browser to improve page reload performance by avoiding extra round trips to the server. This setting is selected by default for all orgs. We don’t recommend disabling this setting. However, if your company’s policy doesn’t allow browser caching even if the data is encrypted, you can disable it.
We've added secure data caching in the browser to improve page reload performance by avoiding additional round trips to the server.

This feature is available in Lightning Experience only.


Reference:


Wednesday, December 13, 2017

Salesforce Lightning: Utility Bar

One of the benefits when you switching to Lightning is Utility Bar. Lightning Experience allows you to add your components to the prime real estate in any Lightning app so that your users have one-click access to powerful productivity tools, such as Recent items, Notes, Chatter feed and so on. Your users can access those same productivity tools in a horizontal footer, called the utility bar.

Utility bar gives your users quick access to common productivity tools. The utility bar is a fixed footer that opens components in docked panels. You can add multiple components to the utility bar, each Lightning Apps can have their own set of components in the utility bar. You also can add the same components many times in the utility bar within the same Lightning apps, this is because some of the components allowed you to select a different type of visibility, e.g. for Chatter Feed components, you can select Bookmarked, What I Follow, and To Me feed.


Utility bar will be available and visible for the users, no matter which page they are open, so this gives instant access to the components, this is even better compare to Classic, where you can add commonly used items in the Home page.

As of now Winter '18 release, Salesforce provide 13 standard components available for utility bar, but you can develop your owned components (need to enable My Domain) or install from AppExchange.


Reference: