v1 - amazon s3...for policies linked t o a cust om obj ect model or domai n-specif i c decision poi...

21
Administrator Guide v1.14 © 2015 Decisions on Demand, Inc. - All Rights Reserved

Upload: others

Post on 05-Jul-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: v1 - Amazon S3...For policies linked t o a cust om obj ect model or domai n-specif i c decision poi nt , we’ll work with you t o i mpl ement a pol i cy t hat meet s your specif i

Administrator Guide v1.14

© 2015 Decisions on Demand, Inc. - All Rights Reserved

Page 2: v1 - Amazon S3...For policies linked t o a cust om obj ect model or domai n-specif i c decision poi nt , we’ll work with you t o i mpl ement a pol i cy t hat meet s your specif i

Table of Contents

Table of Contents

Introduction

Pre-requisites

Additional resources

Document outline

Architecture overview

Decision Server

Policy Management Server

Salesforce AppExchange app

Developer Toolkit

Planning your integration

Installing and configuring policies

Installing policy templates

Configuring a policy

Setting up policy invocation

Invoking a business policy manually

Using a custom button on a record detail page

Using a custom list view button

Running a batch job manually

Invoking a business policy programatically

Running a batch job programatically

Invoking a business policy from a trigger

Setting up an APEX trigger to call the Decisions on Demand API

Activating triggers for a business policy

Invoking a business policy from Visual Workflow

Managing policy lifecycle

Archiving and restoring business policies

Deleting business policies

User access rights

Application components

Functionality

2 © 2016 Decisions on Demand, Inc. - All Rights Reserved

Page 3: v1 - Amazon S3...For policies linked t o a cust om obj ect model or domai n-specif i c decision poi nt , we’ll work with you t o i mpl ement a pol i cy t hat meet s your specif i

Introduction This document is intended for Salesforce system administrators and developers, and explains how to integrate the Decisions on Demand AppExchange app into your Salesforce org.

Pre-requisites

It is assumed you have successfully installed the app from the AppExchange into your Salesforce org. If not, you can download the app from our AppExchange listing: http://bit.ly/decsond-appx.

An Installation Guide is also available from the listing page.

You will need Salesforce System administrator access rights for many of the tasks described in this guide. Certain steps also require some APEX coding.

Additional resources

For an introduction to Decisions on Demand please refer to the Getting Started tutorial at http://bit.ly/decsond-doc114-get-started

It provides a step-by-step tutorial walking you through the basic functionality of the app.

For any additional questions, you can reach us at the following locations:

● Web site: http://www.decisionsondemand.com/contact-us

● Twitter: @decsond

● E-mail: [email protected]

Document outline

This document contains the following sections:

● Architecture overview – shows the main components and their connections ● Planning your integration – questions to ask before starting integration ● Installing and configuring policies – make customized policies available for use ● Setting up policy invocation – set up manual or automatic invocation of policies ● Assigning user access rights – allow users to author and view policies

3 © 2016 Decisions on Demand, Inc. - All Rights Reserved

Page 4: v1 - Amazon S3...For policies linked t o a cust om obj ect model or domai n-specif i c decision poi nt , we’ll work with you t o i mpl ement a pol i cy t hat meet s your specif i

Architecture overview This section gives an overview of the architecture of the Decisions on Demand product, and describes the main components.

Decision Server

The Decision Server applies a business policy to a stateless request received through a REST API. The REST API may be called from within Salesforce using APEX API, or from a VisualForce page using a custom controller/controller extension. See the Setting up policy invocation section for details on the usage and API of relevant components included with the app.

Behind the scenes, the Decision Server obtains business policies in binary executable format from the Policy Management Server.

Policy Management Server

The Policy Management Server stores, and provides access to, versions of policy spreadsheets. It also compiles the spreadsheets into an executable format and makes them available to the Decision Server. The server is also accessible through a REST API, which is wrapped by the components of the AppExchange app.

To compile the policy spreadsheet the Policy Management Server requires a set of configuration files, packaged as a template. Commonly used templates are available for

4 © 2016 Decisions on Demand, Inc. - All Rights Reserved

Page 5: v1 - Amazon S3...For policies linked t o a cust om obj ect model or domai n-specif i c decision poi nt , we’ll work with you t o i mpl ement a pol i cy t hat meet s your specif i

use through the AppExchange app (see Install and configure policy templates). Custom templates can be created using the Developer Toolkit.

Salesforce AppExchange app

The Decisions on Demand AppExchange app provides convenient access to the Decision and Policy Management server from within Salesforce. The main components include:

● VisualForce pages and associated controllers for invoking business policies ● Policy management pages and supporting classes ● APEX classes that provide simple access to the REST APIs for the servers, as

well as extension points.

Developer Toolkit

The Developer Toolkit is used to customize standard policy templates, or create new ones from scratch. The Developer Toolkit is currently only available to Decisions on Demand implementation partners. We plan to make the toolkit available to customers in a future release.

If you have a current need to create a custom policy please contact us at [email protected] -- we offer flat-fee consulting services, and your first custom policy is free with your annual subscription.

Planning your integration Before starting the integration of the app into your Salesforce org, it is helpful to discuss the following questions with the application users:

● Which decisions to automate? Decisions on Demand is best suited to repeatable decisions with well-defined logic that changes frequently. We provide a library of business policy templates for common use cases, including:

o Lead Assignment

o Case Assignment

o Opportunity Discounts

Additional templates can be provided upon request to [email protected].

● When and how to apply automated decision logic? Business policies can be applied manually from a custom button (on Detail page or List view), or automatically from a trigger, batch APEX or VisualWorkflow.

5 © 2016 Decisions on Demand, Inc. - All Rights Reserved

Page 6: v1 - Amazon S3...For policies linked t o a cust om obj ect model or domai n-specif i c decision poi nt , we’ll work with you t o i mpl ement a pol i cy t hat meet s your specif i

● Which users should have access, and to which policies? Standard profiles and permission sets are provided to provide read/write or read-only access. In addition, standard sharing rules can be applied to grant or restrict access to individual policies.

The following sections explain how to configure and integrate the app based on the answers to these questions.

Installing and configuring policies In Decisions on Demand a set of business rules is referred to as a Business Policy. There are two options to create a new business policy:

● Install it from the library of predefined templates The library is a growing collection of templates for common use cases. If you don’t find the template you are looking for, please contact us at [email protected] to submit a suggestion for a new template.

● Request a custom policy For policies linked to a custom object model or domain-specific decision point, we’ll work with you to implement a policy that meets your specific needs – the process usually takes at most a few days.

Please send requests for new templates or custom policies to [email protected].

The remainder of this section explains how to create a new policy from a template.

Installing policy templates

To create a new policy from a template, follow these steps:

1. Open the Decisions on Demand app

6 © 2016 Decisions on Demand, Inc. - All Rights Reserved

Page 7: v1 - Amazon S3...For policies linked t o a cust om obj ect model or domai n-specif i c decision poi nt , we’ll work with you t o i mpl ement a pol i cy t hat meet s your specif i

2. Navigate to the Business Policies tab

3. Click the Install button next to the template of your choice

4. Confirm template is installed

The template should appear under the list of installed business policies. You can then click the policy name to be taken to the detail page where you can edit the business rules.

Configuring a policy

After the policy is installed you can optionally configure it to:

● Add, configure or remove actions

● Show, hide, add or remove columns

● Re-order columns

● Change column titles and width

To configure a policy click on the name in the Available Business policies list. This will open the policy detail page

7 © 2016 Decisions on Demand, Inc. - All Rights Reserved

Page 8: v1 - Amazon S3...For policies linked t o a cust om obj ect model or domai n-specif i c decision poi nt , we’ll work with you t o i mpl ement a pol i cy t hat meet s your specif i

On the policy detail page click the gear icon at the top right of the decision tables view top open the configuration dialog.

Editing of the policy is not in scope for this document. Please refer to the Getting Started tutorial or online help for details.

8 © 2016 Decisions on Demand, Inc. - All Rights Reserved

Page 9: v1 - Amazon S3...For policies linked t o a cust om obj ect model or domai n-specif i c decision poi nt , we’ll work with you t o i mpl ement a pol i cy t hat meet s your specif i

Setting up policy invocation Invoking a business policy involves making a call out to the Decisions on Demand server passing one or more Salesforce objects, in order to obtain a business decision. The results of that decision are returned to Salesforce as a list of actions, which are then applied to Salesforce objects. Examples of actions include assigning a new owner, updating fields, creating new records or sending an email.

This section shows how to configure the various ways in which business policies can be invoked:

● Manually o Using a custom button on a detail page o Using a custom button on a list view o By running a batch job

● Automatically o Through a trigger o Using Scheduled APEX o Using Batch APEX o From a custom VisualForce page o From Visual Workflow

Invoking a business policy manually

You can invoke a business policy manually in three ways: ● Using a custom button on a detail page ● Using a custom button on a list view ● By running a batch job

Using a custom button on a record detail page

The simplest way to invoke a business policy is by adding a custom button to a record detail page. Predefined custom buttons are included in the app for the standard policy templates: Assign (for Lead or Case), Discounts (for Opportunity). You can simply drag these buttons onto a page layout.

9 © 2016 Decisions on Demand, Inc. - All Rights Reserved

Page 10: v1 - Amazon S3...For policies linked t o a cust om obj ect model or domai n-specif i c decision poi nt , we’ll work with you t o i mpl ement a pol i cy t hat meet s your specif i

You can also create your own custom buttons. Your button should use URL as the content source, and Invoke the pre-built DecsOnD__ApplyPolicy VisualForce page.

The configuration will look like this:

Where the URL has the basic form:

{!URLFOR("../apex/DecsOnD__ApplyPolicy", "")}?

ID={!<object type>.Id}&

policy=<policy name>

The full set of supported URL parameters is:

● ID : the identifier of the main object to be passed to the decision server ● policy : the name of the policy to invoke ● mode (optional, default to auto ):

○ auto: policy actions are automatically applied ○ review : user will be asked to review any changes before they are

applied ● log : if true (the default), a Policy Execution Record will be created for the main

object with every decision service invocation. The level of detail for the execution

10 © 2016 Decisions on Demand, Inc. - All Rights Reserved

Page 11: v1 - Amazon S3...For policies linked t o a cust om obj ect model or domai n-specif i c decision poi nt , we’ll work with you t o i mpl ement a pol i cy t hat meet s your specif i

record can be set on the policy through its detail page.

Note: to enable a related list of policy execution records on the main object, a lookup relation must be created from the Policy Execution Record object to the main object. Pre-built relations exist for Lead, Case, Opportunity, Account and Contact. For example:

If you need related lists of policy execution records for other objects, you will need to create a similar relationship with the name of the object (such as Product2__c or MyObject__c ).

Using a custom list view button

It is also possible to execute a business policy on a list of objects from a list view. Pre-defined buttons are included for the standard policy templates.

You can add them from the Search Layouts section of the relevant Salesforce object.

The select the view you want to add the button to, and add it to the Selected buttons

When you next open the selected view, the button should be visible:

11 © 2016 Decisions on Demand, Inc. - All Rights Reserved

Page 12: v1 - Amazon S3...For policies linked t o a cust om obj ect model or domai n-specif i c decision poi nt , we’ll work with you t o i mpl ement a pol i cy t hat meet s your specif i

The user can then select multiple objects in this view and invoke the policy on them in a single action.

The list buttons use the DecsOnD__ApplyPolicyToList VisualForce page. An example configuration looks like:

To create your own, edit the objectName and policyName values, and optionally the mode and log parameters.

Running a batch job manually

On the business policy detail page, you will find a Run Batch button.

12 © 2016 Decisions on Demand, Inc. - All Rights Reserved

Page 13: v1 - Amazon S3...For policies linked t o a cust om obj ect model or domai n-specif i c decision poi nt , we’ll work with you t o i mpl ement a pol i cy t hat meet s your specif i

Note: the button is greyed out when the selected version is a draft.

A dialog appears that allows you to specify the parameter of the batch job

You can enter the following

● Where Clause This allows you to select a subset of records to which the policy will be applied. For example, Industry = ’Technology’ will select only records with the Industry field set to Technology . The format of the where clause is defined by the SOQL language, see https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql_select_conditionexpression.htm for details. To validate the syntax of your where clause, press the Tab key or click outside of the text box. This will also display the number of records that match the condition.

● Batch Size This is a number up to 2000 that specifies the number of records to process in one go. This is optional -- use it only if you encounter issues related to Salesforce governor limits. Lower values will avoid these issues, at the expense of slowing down you batch job somewhat.

● Send email on completion Whether you would like to receive an email on completion of the batch, only on failure, or not at all

13 © 2016 Decisions on Demand, Inc. - All Rights Reserved

Page 14: v1 - Amazon S3...For policies linked t o a cust om obj ect model or domai n-specif i c decision poi nt , we’ll work with you t o i mpl ement a pol i cy t hat meet s your specif i

Click Run Batch to launch the job. You will see a confirmation as follows:

To track progress of the job, go to Setup/Monitor/Jobs/APEX jobs

Invoking a business policy programatically

You can invoke a business policy programatically from: ● A trigger ● Batch APEX ● Scheduled APEX ● A custom VisualForce page ● Visual Workflow

Invoking a business policy from a trigger

You can invoke a business policy automatically when records in Salesforce are created or updated. To do this, follow these steps:

● Call the Decisions on Demand API from an APEX trigger on all relevant objects ● Activate the trigger for all relevant policies

Setting up an APEX trigger to call the Decisions on Demand API

To apply a business policy when records are created or updated, you need to invoke the Decisions on Demand API from an APEX trigger for each object that should trigger a re-evaluation of the rules.

That typically includes the main object to which the policy applies, but may also include related objects. For instance, to reassign an account when an associated opportunity is created, updated or deleted, you would need to create a trigger on the Opportunity object.

The Decisions on Demand API call may be embedded in an existing trigger, or you can create a new trigger.

The code below shows a complete trigger for the Lead object. To modify it for another object simply replace all occurrences of Lead with the name of the object in question -- which can be standard or custom.

14 © 2016 Decisions on Demand, Inc. - All Rights Reserved

Page 15: v1 - Amazon S3...For policies linked t o a cust om obj ect model or domai n-specif i c decision poi nt , we’ll work with you t o i mpl ement a pol i cy t hat meet s your specif i

Note that a Decisions on Demand policy:

● Will be invoked asynchronously -- any actions will not be applied until after the trigger completes

● Should only be applied on after events for insert, update or delete -- API calls from a before or undelete triggers are ignored.

If you have an existing trigger, you can embed the calls to the TriggerExecutionHandler methods into your existing code.

Activating triggers for a business policy

Setting up the trigger in the step above will call the Decisions on Demand API whenever relevant insert,update or delete events occur. This can result in the invocation of zero or more business policies.

15 © 2016 Decisions on Demand, Inc. - All Rights Reserved

Page 16: v1 - Amazon S3...For policies linked t o a cust om obj ect model or domai n-specif i c decision poi nt , we’ll work with you t o i mpl ement a pol i cy t hat meet s your specif i

To activate and configure trigger-based invocation for a specific policy, go to the Triggers section on the policy detail page. There, you can select the objects and events that shoudl trigger a re-evaluation of the rules. You can also indicate in which cases you would like an Execution record to be created, and whether to send you an email on trigger failure.

For instance, to invoke a policy only on creation of a new Lead, configure the triggers as follows:

Or to invoke a policy only on creation or update of an account, as well as any events on associated Opportunities and create or update events on Contacts, use the following settings:

Invoking a policy from Batch APEX

Use the BatchExecutePolicy class, which implements the Database.Batchable

APEX interface. BatchExecutePolicy has two constructors:

PolicyInvocationContext describes the parameters of the policy invocation:

● Salesforce object type ● Policy name

whereConditions or whereClause are used to specify which instances of the Salesforce object type to include in the batch.

16 © 2016 Decisions on Demand, Inc. - All Rights Reserved

Page 17: v1 - Amazon S3...For policies linked t o a cust om obj ect model or domai n-specif i c decision poi nt , we’ll work with you t o i mpl ement a pol i cy t hat meet s your specif i

For instance, the following code would create a batch that applies the Assignment policy to all the leads located in the USA:

Invoking a policy from Scheduled APEX

To invoke a policy from Scheduled APEX, create a class that implements the System.Schedulable interface, then implement the execute method to call BatchExecutePolicy as described in the previous section.

Invoking a business policy from a custom VisualForce page

To invoke a policy from a custom VisualForce page, add the DecsonD.ApplyPolicyControllerExtension class to an existing VisualForce page with a standard controller and invoke it from a custom button as described above under “Using a custom button on a record detail page”.

Invoking a business policy from Visual Workflow

The app includes a custom VisualWorkflow plugin:

The plugin has the following parameters:

17 © 2016 Decisions on Demand, Inc. - All Rights Reserved

Page 18: v1 - Amazon S3...For policies linked t o a cust om obj ect model or domai n-specif i c decision poi nt , we’ll work with you t o i mpl ement a pol i cy t hat meet s your specif i

The meanings of the input parameters are the same as described under Invoking a business policy from a detail page above. Only the sObjId and policyName parameters are required. Note that the object type is inferred from the object ID.

Possible resultStatus parameter values are OK, FAIL or NO_ACTION.

Managing policy lifecycle Archiving and restoring business policies

When a policy is no longer needed, you can archive it. An archived policy is still visible, but can no longer be invoked. To archive a policy, edit the Status field by clicking the Change link next to the Status value.

and confirm the action:

Archived policies can be viewed from the Policies tab by choosing the All view. To restore an archived policy open its detail page and change the status back to Active.

18 © 2016 Decisions on Demand, Inc. - All Rights Reserved

Page 19: v1 - Amazon S3...For policies linked t o a cust om obj ect model or domai n-specif i c decision poi nt , we’ll work with you t o i mpl ement a pol i cy t hat meet s your specif i

Deleting business policies

Only Salesforce system administrators can delete a policy, since this will remove it from the Decisions on Demand server as well as from Salesforce, and all version history will be lost. It is recommended to Archive policies that have associated version history instead.

19 © 2016 Decisions on Demand, Inc. - All Rights Reserved

Page 20: v1 - Amazon S3...For policies linked t o a cust om obj ect model or domai n-specif i c decision poi nt , we’ll work with you t o i mpl ement a pol i cy t hat meet s your specif i

User access rights The app includes the following profiles and permission sets:

● Decisions on Demand Administrator ● Decisions on Demand Reviewer ● Decisions on Demand User

The profiles can be assigned to existing user profiles when the app is installed. The permission sets can be used to grant access to individual users at any time after installation.

In both cases, the profiles determine access to the main components and functionalities of the app:

Application components

Administrator Reviewer User Decisions on Demand app

Yes Yes No

Welcome tab Yes Yes

N/A

Business Policies tab Yes Yes

Policy Execution Records tab

Yes No

Functionality

Administrator Reviewer User Install template Yes No No

Edit policy Yes Sharing (RW) No

Change active version Yes Sharing No

View policy meta-data Yes Sharing Sharing

View policy execution log Yes Sharing Sharing

View policy audit trail Yes Sharing No

View policy content Yes Sharing No

Apply policy Yes Yes Yes

Archive/restore policy Yes No No

Delete policy No No No

20 © 2016 Decisions on Demand, Inc. - All Rights Reserved

Page 21: v1 - Amazon S3...For policies linked t o a cust om obj ect model or domai n-specif i c decision poi nt , we’ll work with you t o i mpl ement a pol i cy t hat meet s your specif i

In the table above, ‘Sharing’ means that the access to individual policies is controlled by standard Salesforce sharing rules.

Only a Salesforce Administrator can delete a policy – but a Decisions on Demand administrator can archive it as explained under Managing policy lifecycle above.

21 © 2016 Decisions on Demand, Inc. - All Rights Reserved