Embedded app templates can create apps without any custom code, but you can add customizations to your embedded app lifecycle. Create Apex classes that use the CRM Analytics auto-installer to create and manage auto-install requests for your embedded app.
What Is the CRM Analytics Auto-Installer?
The CRM Analytics auto-installer is a metadata-based API that manages the lifecycle of a CRM Analytics templated app. No user access to CRM Analytics Studio and the template configuration wizard is required.
The auto-installer provides management functionality for embedded apps. Creating customized runtime functionality requires knowledge of Apex. Auto-install requests can also be managed via Analytics CLI Plugin commands or using Connect API REST calls.
Limits and Restrictions
Concurrent Auto-Install Requests
The auto-installer uses asynchronous processing that allows a maximum of 10 Enqueued, InProgress, or AppInProgress requests at a time. Until existing requests complete their cycle or their RequestStatus is updated to Cancelled, no more requests can transition from New to Enqueued.
App-Specific Concurrent Requests
No app-specific auto-install WaveAppDelete, StartDataflow, WaveAppUpdate requests can be Enqueued until existing requests that are in progress are completed or canceled with the same folder id.
Cancellation Policy
If an auto-install request is canceled, the auto-installer attempts to abort the request, but there’s no guarantee when or if the request can be aborted.
Auto-Installer Use Cases
These use cases show how to create customized auto-install app management using Apex code. Examples include enabling CRM Analytics in the install org, configuring the app creation settings, and creating and updating embedded apps.
CRM Analytics Enablement
Any use of a CRM Analytics templated app requires the CRM Analytics preference to be enabled before an app can be created and managed.
The CRM Analytics auto-installer can automatically enable this preference so any other auto-installer task can be taken. The auto-installer can enable or disable any of these preferences based on the Auto-Installer configuration specified by the API caller:
CRM Analytics Replication
Sharing Inheritance
Apex Example
1Map<String, Object>configuration = new Map<String, Object>();2Map<String, Object>waveEnableConfiguration = new Map<String,Object>();3waveEnableConfiguration.put('replicationEnabled', true);4waveEnableConfiguration.put('templatesEnabled', true);5waveEnableConfiguration.put('inheritedSharingEnabled', true);6configuration.put('waveEnableConfiguration', waveEnableConfiguration);7WaveAutoInstallRequest newRequest = new WaveAutoInstallRequest();8newRequest.put('Name', 'Test WaveEnable request');9newRequest.put('RequestStatus', 'Enqueued');10newRequest.put('RequestType', 'WaveEnable');11newRequest.put('Configuration', JSON.serialize(configuration));12insert newRequest;
For information on auto-install requests and auto-install configuration metadata, see:
The WaveAppCreate auto-install task creates a CRM Analytics app based on the TemplateApiName and values specified by the caller.
After the app creation process is complete, the auto-install request is updated automatically by the app template framework. If deleteAppOnConstructionFailure is set to true and the app fails to create, the app is automatically deleted.
1Map<String, Object>configuration = new Map<String, Object>();2Map<String, Object>values = new Map<String, Object>();3values.put(‘myVariableName1’,’someValue’);4Map<String, Object>appConfiguration = new Map<String,Object>();5appConfiguration.put('deleteAppOnConstructionFailure', true);6appConfiguration.put('values', values);7configuration.put('appConfiguration', appConfiguration);8WaveAutoInstallRequest newRequest = new WaveAutoInstallRequest();9newRequest.put('Name', 'Test WaveAppCreate request');10newRequest.put(‘TemplateApiName’, 'template_test');11newRequest.put('RequestStatus', 'Enqueued');12newRequest.put('RequestType', 'WaveAppCreate');13newRequest.put('Configuration', JSON.serialize(configuration));14insert newRequest;
App Update
The WaveAppUpdate auto-install task performs an upgrade or reset on an existing CRM Analytics app based on the TemplateApiName, the FolderId of the app, and values specified by the caller.
After the app update is completed, the app template framework automatically updates the auto-install request. If deleteAppOnConstructionFailure is set to true and the app fails to update, the app is automatically deleted.
1Map<String, Object>configuration = new Map<String, Object>();2Map<String, Object>values = new Map<String, Object>();3values.put(‘myVariableName1’,’someValue’);4Map<String, Object>appConfiguration = new Map<String,Object>();5appConfiguration.put('deleteAppOnConstructionFailure', true);6appConfiguration.put('values', values);7configuration.put('appConfiguration', appConfiguration);8WaveAutoInstallRequest newRequest = new WaveAutoInstallRequest();9newRequest.put('Name', 'Test WaveAppUpdate request');10newRequest.put(‘TemplateApiName’, 'template_test');11newRequest.put('RequestStatus', 'Enqueued');12newRequest.put('FolderId', '<folder_id>');13newRequest.put('RequestType', 'WaveAppUpdate');14newRequest.put('Configuration', JSON.serialize(configuration));15insert newRequest;
App Delete
The WaveAppDelete auto-install task simply deletes an existing CRM Analytics app based on the TemplateApiName and FolderId that the caller specifies.
No auto-install requests can be in progress for the specified folder id when the delete request is enqueued.
1WaveAutoInstallRequest newRequest = new WaveAutoInstallRequest();2newRequest.put('Name', 'Test WaveAppDelete request');3newRequest.put('RequestStatus', 'Enqueued');4newRequest.put('FolderId', '<folder_id>');5newRequest.put('RequestType', 'WaveAppDelete');6// Not required, but best practice is to add the attribute so that related7// requests are aggregated together by template api name and folder.8newRequest.put(‘TemplateApiName’, 'template_test');9insert newRequest;
Start Dataflow
The StartDataflow auto-install task executes a dataflow for the specified folder. Dataflow execution is only allowed for apps that are based on an Embedded App template.
After the dataflow is completed, the templating framework automatically marks the auto-install request as completed.
The CRM Analytics Auto-Install Request framework is dependent on asynchronous processing, making it impossible to assure ordering of multiple auto-install requests.
To create request ordering, that auto-installer uses auto-install request dependencies, which guarantee that one auto-install request runs and finishes before another related auto-install request executes. Auto-install request dependencies don’t guarantee that dependencies are executed before other enqueued requests that aren’t part of the dependency chain.
Auto-install requests that have dependencies on other requests must have a status of New to be auto-enqueued by the framework. Dependencies with any other status are ignored.
If any auto-install request in the request hierarchy fails for any reason (including canceled), subsequent related requests auto-fail as well.
Request dependencies have these limits:
A single auto-install request can depend on up to 10 other auto-install requests, directly or indirectly through the dependency chain.
All parent auto-install requests must exist and be in New status before the child can declare a dependency on a parent request.
1//Create first request with a new status (do not enqueue yet)2sObject firstRequest = Schema.getGlobalDescribe().get('WaveAutoInstallRequest').newSObject();3firstRequest.put('Name', requestName);4firstRequest.put('RequestStatus', 'New');5firstRequest.put('RequestType', 'WaveAppCreate');6firstRequest.put('TemplateApiName', 'template_test');7insert firstRequest;89//Create second request with a new status. This is enqueued after the first request is done.10sObject secondRequest = Schema.getGlobalDescribe().get('WaveAutoInstallRequest').newSObject();11secondRequest.put('Name', 'Dependant Request');12secondRequest.put('RequestStatus', 'New');13secondRequest.put('RequestType', 'WaveAppCreate');14secondRequest.put('TemplateApiName', 'template_test');1516//Set up configuration for the second request, containing the id from the first17Map<String, Object>configuration = new Map<String, Object>();18configuration.put('parentRequestIds', new List<String>{firstRequest.Id});19secondRequest.put('Configuration', JSON.serialize(configuration));2021insert secondRequest;2223//update the first request to enqueue.24firstRequest.put('RequestStatus', 'Enqueued');25update firstRequest;