Pages

Sunday, August 5, 2018

Einstein Analytics: Dashboard API Name

As usual Salesforce stuff, we have label and name (read API name) for an object, field, dashboard, and etc. But, is there such things in the Einstein Analytics for the dashboard? Yes, there is, although you do not always need to know the API name, however, in some scenario, you need to know.

When you edit a dashboard, you only change the title, same goes to the lens. Let looks at dashboard JSON, the second line of the dashboard will say "label": "dashboard name", we can easily change the label, but can we get the dashboard API name?

Scenario: I create a dashboard called "backup map", by default the API name would be backup_map, this is just by replacing space with _.
After a while, I change the label from "backup map" to "my map", will the API name change from backup_map to my_map? The answer is No.

Here 2 options can be used to get dashboard API name:

1. Use Link Widget
Create a new dashboard, add link widget and select link to Saved dashboard, and select the dashboard you would like to check.



Now, open dashboard JSON, and looks for link_1 (for this sample) widget, here we go:
       "widgets": {
            "link_1": {
                "type": "link",
                "parameters": {
                    "destinationType": "dashboard",
                    "includeState": false,
                    "text": "Button title",
                    "textColor": "#44A2F5",
                    "textAlignment": "center",
                    "fontSize": 12,
                    "destinationLink": {
                        "name": "backup_map"
                    }
                }
            }
        },


2. Workbench
Workbench is a powerful tool, love by all Salesforce developer and admin, also for us as Einstein Analytics power user.

Once you login to Workbench, navigate to utilities - REST Explorer, change the URI to /services/data/v43.0/wave/dashboards then click Execute button, then click Expand All link. Here, you will find everything you need to know about your dashboards. From the screenshot below, the API name is "backup_map", while the label has been changed to "my map".



You can also evaluate other stuff in Einstein Analytics by changing the URI to /services/data/v43.0/wave/





Salesforce Lightning: Log a Call button does not appear in Activity component

For those of you who have been migrated from Classic to Lightning, you notice that "Open Activities" and "Activity History" are no longer appeared in the related list, instead, they appear as a Lightning component called Activity. Log a Call, New Task, and New Event will not show as buttons anymore, but as tabs under the Activity component, as they appear as a separate component, users can enter the data without leaving the main detail page.


However, if you don't see those tabs under the Activity component, here are a few things you should check:

1. Page Layout
Yes, I am referring to the Classic page layout, not Lightning Page. If you have multiple page layout based on profile or record type or both. Make sure you are checking the correct page layout.

Open a record, click the gear icon, then Edit Page link, click Details tab, then click the layout in Details tab, check the page layout name with (previewed).



Now, go to that page layout -- back to the record page, click the Edit Object link under the gear icon, select the Page Layouts menu, then click the same page layout showed in the previewed earlier.

Make sure Log a CallNew Task, and New Event are added into the Salesforce Mobile and Lightning Experience Actions section.



2. Record Type
Check if you have record type defined (even only one) in Task and Event, make sure they are selected in the global action because "one action only for one record type".



Now go to Global Actions under the Setup menu, click edit on Log a Call action. In the Record Type, change --Master-- to Special, and click the Save button.



Now, back to the record page and check the Activity component, you should see the Log a Call action appear under the Activity component. The same for the New Task action, it should appear too once you fix the Global Action.



For New Event action (as it is Event object), check if you have Record Type defined in the Event, if yes, you need to do the same for New Event action to define the Record Type.


Reference:



Wednesday, August 1, 2018

Einstein Analytics: Connect Date Source with Date

In previous blog Connect Data Sources and Binding between Dataset, we share about using Connect Data Sources and binding to connect dataset. This blog will share tips:
- how to connect data sources between Date and Dimension.
- how to create list value using Date field


Use Case 1: Sales date is stored in Actual dataset, while Target amount is in Target dataset. We would like to show both actual and target in a dashboard when a certain month and year are selected.

Steps:
1. Target data
Load Year and Month as 2 fields, load both fields as Dimension, not as Measure (Number).

2. Add List
Add List for both Year and Month to the dashboard.

3. Connect Data Source for Month
For Data Source 1, select Month from Target -- here Month is Dimension. For Data Source 2, we can't select Date or type Date_Month from Actual (it is a Date field), so just select any Dimension field for temporary, in this sample, I select Sales_Rep. My dataset API name for Target is Text_Month, and for Actual is Sales_by_Date.


4. Edit dashboard JSON
Einstein Analytics by default will auto parse date field into many fields, e.g. FieldName_Year, FieldName_Month, FieldName_Date, and other FieldName_xxx, we can connect target Month with FieldName_Month by editing dashboard JSON, change the temporary Dimension field name Sales_Rep with Date_Month.

5. Connect Data Source for Year
From dashboard JSON, copy and paste in from Month, and change to Year as a newly connected data source.

       "dataSourceLinks": [
            {
                "fields": [
                    {
                        "dataSourceName": "Text_Month",
                        "dataSourceType": "saql",
                        "fieldName": "Month"
                    },
                    {
                        "dataSourceName": "Sales_by_Date",
                        "dataSourceType": "saql",
                        "fieldName": "Date_Month"
                    }
                ],
                "label": "Month",
                "name": "Link_4521"
            },
            {
                "fields": [
                    {
                        "dataSourceName": "Text_Month",
                        "dataSourceType": "saql",
                        "fieldName": "Year"
                    },
                    {
                        "dataSourceName": "Sales_by_Date",
                        "dataSourceType": "saql",
                        "fieldName": "Date_Year"
                    }
                ],
                "label": "Year",
                "name": "Link_4522"
            }
        ]




6. The moment of Truth




Use Case 2: Target is stored as a Date field.

Steps:
1. Add List
Add List for both Year and Month to the dashboard, you cannot select Date field for List, so just select any Dimension field temporary.

2. Edit List
Edit the List and change the Bars by selecting Date then Month for Month list, and select Date then Year for Year list.


You also can manually edit dashboard JSON, looks the query and change the group to Date_Month for month list, and Date_Year for the year list.

                "query": {
                    "groups": [
                        "Date_Year"
                    ],
                    "measures": [
                        [
                            "count",
                            "*"
                        ]
                    ]
                }

When you go back to edit the widget, notice that now it group by Date (Year) or Date (Month) for each list.



3. Connect Data Source for Month 
Because you can't select Year and Month from both target and actual, just select any Dimension field as a temporary placeholder, edit dashboard JSON and change with Date_Month for both data source. Copy from Month to Year. My dataset API name for Target is Target, and for Actual is Sales_by_Date.

            {
                "name": "Link_2009",
                "label": "Date_Year",
                "fields": [
                    {
                        "fieldName": "Date_Year",
                        "dataSourceName": "Sales_by_Date",
                        "dataSourceType": "saql"
                    },
                    {
                        "fieldName": "Date_Year",
                        "dataSourceName": "Target",
                        "dataSourceType": "saql"
                    }
                ]
            },
            {
                "name": "Link_2010",
                "label": "Date_Month",
                "fields": [
                    {
                        "fieldName": "Date_Month",
                        "dataSourceName": "Sales_by_Date",
                        "dataSourceType": "saql"
                    },
                    {
                        "fieldName": "Date_Month",
                        "dataSourceName": "Target",
                        "dataSourceType": "saql"
                    }
                ]
            }




4. The moment of Truth




Extra: to concatenate string in SAQL, use +
example: 'CreatedDate_Year' + "-" + 'CreatedDate_Month' + "-" + 'CreatedDate_Day'