In this pattern, you will use multiple Real-time Integration Scenarios to show real-time SAP data related to the record shown in a record detail page. You will use Overcast Components to create a widget view, detail view, and list view of SAP data.
This pattern will focus on Overcast Components shown in a Salesforce record detail page, but Overcast Components are not restricted or limited to only record detail page. Overcast Components use Salesforce Lightning Component technology and thus can be used anywhere Lightning Components can.
You should choose Overcast Components when
Users need live data / the data changes frequently.
The Salesforce application does not require the data to function.
The data set is too large to synchronize into Salesforce (with this pattern, you only load the specific data that the user needs to see).
Users need access to a process in SAP that should not be or cannot reasonably be replicated into Salesforce (copying data mostly implies copying business logic).
The disadvantages of this pattern are the following.
Does not integrate SAP data into Salesforce records because it is read-only.
Since no data is stored in Salesforce, it cannot be used in conjunction with Salesforce Reporting and Flows/Workflows.
Does not save data to SAP because it is read-only.
There are other patterns that do not have these disadvantages.
Make sure to remove unused fields or entities/data structures. Larger APIs take longer to process. The larger the API, the larger the component metadata definition, and the longer the load and display time.
Prefer a few smaller, simpler components than one large, complex composite component.
Avoid displaying too much data in one view, or one record. If the user wants more details, allow them to click the record to view the details.
Overcast Component real-time requests are logged in the Monitoring screen when an error occurs or when the log level is set to debug or greater. Overcast Component real-time requests can be very frequent, so successful requests are not logged to avoid unnecessary logging. Custom logs can be output from Enhancement Points.
Audit logs for all requests to the Overcast Service can be obtained from Vigience.
For development and debugging, the log level for the Real-Time Integration Scenario that backs the Overcast Components can be changed to log request data. This change should not be made in production because of the sheer volume of logging that will result.
System errors are logged to the Monitoring screen when a request fails. The failed requests should be retried by the user after the system is restored.
Business errors, like when data is not found or there are bad inputs, are returned to the end user and shown in a toast message to the user. They are not logged to the Monitoring screen.
You can output your own logs using the enhancement point for each component. Your Apex debug logs will available in the Salesforce Developer Console. Read the documentation here to output logs to the Monitoring screen.
Customizations to Overcast Components are primarily made in the Component Builder. There we can perform changes to the configuration of the component, like displaying or hiding fields, adding or removing sections, and creating the links between records and input parameters.
To implement advanced transformations on data before displaying it to the user, or customizing the UI at runtime based on data, custom code can be executed by creating a plugin class for each Overcast Component. Read the API documentation here for creating a plugin class.
Components support multiple languages. To display UI text in the user's display language add Salesforce Custom Labels to section and field labels, then add translations to those Custom Labels.
Many of the standard Overcast Components are already multi-language enabled by using Custom Labels. Add translations to those custom labels for the languages you need.
It is recommended to use Custom Labels in the field labels instead of replacing text with translations directly because workforces are diverse and businesses grow, so it becomes more likely that your users will use different display languages.
To retrieve localized response data, when supported by the backend system, per-user authentication should be used so the backend system will use the user's language to retrieve localized texts.
This section describes the implementation steps for this design pattern.
In this example, you will learn how to display SAP invoice data on a Salesforce account record. Initially, it will show a few invoices in the widget, and then show more when the user clicks for more, and display the invoice details when the user clicks an invoice.
This example is described in a step-by-step tutorial here.
In this example, you will learn how to display SAP customer data on a Salesforce account record. Initially, it will show a few fields, then when the user clicks for more details it will show all fields.
Create a new Real-Time Integration Scenario. Set the name as SAPCustomersRT and give it a description. Select the SAP Connection String and search for KNA1VV. This will create a single Apex class for the Integration Scenario called SAPCustomerRT.cls.
Select the following fields
|
KUNNR |
Customer number |
|
VKORG |
Sales Org. |
|
VTWEG |
Distr. Channel |
|
SPART |
Division |
|
INCO1 |
Incoterms |
|
INCO2 |
Incoterms 2 |
|
STCD1 |
Tax Number 1 |
|
STCD2 |
Tax Number 2 |
|
STKZA |
Equalization tax |
|
STKZU |
Liable for VAT |
|
STCEG |
VAT Reg. No. |
Leave all options as default values.
Save & Activate the Integration Scenario.
On the Integration Scenario screen after the activation completed successfully, click Create Component from the Overcast Components section. This is for the summary widget.
Set Label to Customer Summary and Name to CustomerSummary and click Create component.
In the Preview Settings modal
Preview object = Account
For Preview record, search for an existing record.
Preview component type = Widget
Open Parameter Mappings tab.
Click New. Now we link the SAP customer number from the account record to the KUNNR field on KNA1VV.
Parameter = KNA1VV
Field = KUNNR
Reference Type = Reference Field
Reference Value = SAP Account Identifier
Open Sections tab.
Select Query Parameters.
Turn off the Query Parameters section. This removes the filter button, which is next to the refresh button.
Hide all fields except KUNNR.
Select Query Results.
Hide all fields except INCO1 and INCO2.
Set Section Settings.
Remove the Label.
Structure Type = Structure
Section Type = Panel
Click Update Preview. Click the refresh button in the preview to show data from SAP.
Click Save.
Now, for the detail widget, we will clone the summary widget. Click Save as.
Label = Customer Detail
Developer Name = CustomerDetail
Now, we will add all the fields to the CustomerDetail component.
Open the Component tab.
Set Static Label = Customer Detail.
Click Dynamic label options.
Add the following JSON snippet.
{
"parameters": [
"FIELD:KNA1VV.KUNNR"
],
"template": "Customer Detail ({0})"
}
Open the Sections tab, select the output section, No Label (previously Query Results), then the Fields tab, then click Show All.
Click Save.
Open the CustomerSummary component again. We will add a link so the user can navigate to CustomerDetail.
In the Component tab, click Master action link. At the time of writing, a JSON text entry modal appears.
Add the following JSON snippet.
{
"action": {
"component": "DetailViewer",
"componentDef": "CustomerDetail"
},
"label": "View more"
}
Here we will describe how to create a plugin for the Overcast Components, CustomerSummary & CustomerDetail, from SAP table implementation example.
This sample code will print "No value" for each blank field. It reads the fields from the component so that when a field is added or removed from the component the code does not need to be updated.
Create a class called CustomerComponentPlugin.
Copy the plugin template from here.
Replace afterScenarioCall() from the template with this snippet.
global void afterScenarioCall(
Map<String, Object> returnedData,
overcast.ComponentDefinition.Component cmp,
Map<String, Object> settings
) {
// Set all blank fields to report the text "No value".
List<Object> records = (List<Object>)returnedData.get('KNA1VV');
if (records == null || records.isEmpty()) {
return;
}
// Check if the definition has changed is not what we expect.
// You can alternatively throw an exception to alert the tester that
// this code needs to be updated too.
if (cmp.sections == null || cmp.sections.size() < 2 || cmp.sections[1].structureName != 'KNA1VV') {
return;
}
Map<String, Object> record = (Map<String, Object>)records[0];
// Read the field names from the component.
for (overcast.ComponentDefinition.Field field : cmp.sections[1].fields) {
if (String.isEmpty(String.valueOf(record.get(field.name)))) {
record.put(field.name, 'No value');
}
}
}
Open CustomerSummary component in the Component Builder.
Click Component Settings.
Set Apex Plugin Class = CustomerComponentPlugin
Click Save component.
Perform the same step for CustomerDetail.
With both components saved, reload the Account page and review the changes. The plugin will display the text "No value" for blank fields.
Custom logging can be output from the enhancement point Apex class. The template contains a logger, which we will use.
Add this text at the end of the afterScenarioCall() method to output an INFO level log.
this.logger.addLog(overcast.LogLevel.INFO, 'Added text "No value" to blank fields.');
Normally, requests via an Overcast Component do not appear in the Monitoring screen, but this will add a log to the request so an entry will appear in the Monitoring screen.
Follow the steps below Custom Labels to an Overcast Component in the Component Builder for each location.
Dynamic component label. In the SAP table implementation example above, you added a dynamic label. Let's Rreplace the template with a Custom Label.
Create a Custom Label named CustomerComponentTitleTemplate with the text "Customer Detail ({0})".
Add all required translations to the Custom Label.
Update the template with the Custom Label
{
"parameters": [
"FIELD:KNA1VV.KUNNR"
],
"template": "$Label.c.CustomerComponentTitleTemplate"
}
Static component label. In the SAP table implementation example above, you added a static label for the summary component. Replace the static label with a Custom Label.
Create a Custom Label named CustomerComponentTitle with the text "Customer Summary".
Add all required translations to the Custom Label.
Replace label with $Label.c.CustomerComponentTitle.
Sections and fields. Add Custom Labels to section and field labels in this format $Label.c.LabelName. This is the same method for the static component label.
To retrieve localized response data, when supported by the backend system, per-user authentication should be used so the backend system will use the user's language to retrieve localized texts.