IUnifiedHealthScore Interface
Namespace
Usage
Actions triggered from the Dynamic Actions for Unified Health Scoring component are logged in the Health Score Action Log object. You can customize the information logged in this object using the IUnifiedHealthScore Apex interface in a custom Apex class.
IUnifiedHealthScore Methods
The following are methods for IUnifiedHealthScore.
saveActionDetail(var1)
Stores health score information in the Health Score Action Log object.
The action history logged in Health Score Action Log doesn’t include score information by
default.
Signature
public Boolean saveActionDetail(Map<String,String> var1)
1healthcloudext.IUnifiedHealthScore, saveActionDetail, [Map<String,String>], BooleanParameters
- var1
- Type: Map<String,String>
- A map of key-value pairs for the attributes, including subject ID, action status, action date, action label, action name, action description, action icon URL, and performed by ID.
Return Value
Type: Boolean
IUnifiedHealthScore Example Implementation
This example shows an implementation of the healthcloudext.IUnifiedHealthScore interface.
Using this sample code, your action logs now also mention the specified score category and its score value at the time the action was triggered.
1global class ApexClassForCustomLogs implements healthcloudext.IUnifiedHealthScore{//IMPORTANT: replace CustomActionLog with the name the Apex class
2 public Boolean saveActionDetail(Map<String, String> request){
3 try {
4 String aSubject = request.get('subjectId');
5 List<HealthScore> aHealthScore = [select CurrentScore from HealthScore where SubjectId=:aSubject and ScoreCategoryId='0gzRN00000001drYAA'];
6 //IMPORTANT: Replace 0gzRN00000001drYAA with the Id of your score category.
7 List<HealthScoreActionLog> acctList = new List<HealthScoreActionLog>();
8 HealthScoreActionLog aHealthScoreActionLog = new HealthScoreActionLog(
9 ActionDescription=request.get('actionDescription'),
10 ActionIconUrl=request.get('actionIconUrl'),
11 ActionLabel=request.get('actionLabel'),
12 ActionName=request.get('actionName'),
13 ActionStatus=request.get('actionStatus'),
14 PerformedById=request.get('performedById'),
15 SubjectId=request.get('subjectId'),
16 ActionDate=datetime.now(),
17 Score=aHealthScore[0].CurrentScore,
18 ScoreCategoryId='0gzRN00000001drYAA'//IMPORTANT: Replace 0gzRN00000001drYAA with the Id of your score category.
19 );
20 acctList.add(aHealthScoreActionLog);
21 Database.SaveResult[] srList = Database.insert(acctList, false);
22 for (Database.SaveResult sr : srList) {
23 if (sr.isSuccess()) {
24 // Operation was successful, so get the ID of the record that was processed
25 System.debug('Successfully inserted account. HealthScoreActionLog ID: ' + sr.getId());
26 }
27 else {
28 // Operation failed, so get all errors
29 for(Database.Error err : sr.getErrors()) {
30 System.debug('The following error has occurred.');
31 System.debug(err.getStatusCode() + ': ' + err.getMessage());
32 System.debug('Account fields that affected this error: ' + err.getFields());
33 }
34 }
35}
36 //insert aHealthScoreActionLog;
37 return true;
38 }catch(DmlException e) {
39 System.debug('An unexpected error has occurred: ' + e.getMessage());
40 return false;
41 }
42 }
43}