You are here:
InsScheduledAutomatedTransitionService:scheduleAutomatedTransition
Use this service to automate the state transition by scheduling an object state transition, from an origin state to a target state (Vlocity States), using hourly, daily, or weekly patterns.
Class: InsScheduledAutomatedTransitionService
Method: scheduleAutomatedTransition
How It Works
This transition is for Vlocity State Model workflows. Complex scheduling patterns (every two days, every first Monday of the month, etc.) are not supported.
-
With the objectName and fieldName (and the optional typeName and typeValue) inputs, the specific Vlocity State Model Version that represents the workflow is determined.
-
With the fromState and toState inputs, the specific Vlocity State Transition within that workflow, i.e, within the Vlocity State Model Version from the previous step, is determined. The schedule inputs provide information on how often and when to run a Salesforce scheduled job that would perform the automated state transition, from the 'fromState' to 'toState'. Every time the scheduled job runs, it performs these actions:
-
Retrieve up to 5 instances of the type represented by 'objectName', where the value of the field represented by 'fieldName' = the value represented by 'fromState'. This ensures that only those object instances that are currently in the state represented by the 'fromState' are picked for performing the transition.
-
All the configured Vlocity State Transition rules for the specified Vlocity State Transition (as determined from Step 2 above) are executed.
-
If the overall result from the rule execution (which is governed by the Transition Completion Criteria set on the Vlocity State Transition) is true, such as the rule execution passed, the object instance's state is updated to the state and represented by the 'toState'.
-
If the overall result from the rule execution is false, i.e. the rule execution failed, then the object instance's state is updated to the Alternate state configured in the Vlocity State Transition if it exists.
-
If the object instance's state gets updated to a new state (either 'toState' or the Alternate state for the specified Transition), the corresponding Vlocity Actions configured for that state (i.e. the 'To State' field in Vlocity Action) are executed.
-
The number of object instances whose state was updated to 'toState' is returned in 'noOfUpdatedRecords'. The number of object instances whose state was updated to the Alternate state is returned in 'noOfUpdatedRecordsToAlternateStates'.
-
If no transition was performed, the object instance remains in the 'fromState'.
-
Inputs
Input |
Description |
|---|---|
|
Required. Object API name |
|
Required. Field API name that hosts the state value. |
|
Required. From State (origin) field value of the state transition. |
|
Required. To State (target) field value of the state transition. |
|
Optional.
|
|
Optional.
Note
For example, with typeName = 'Type__c' and typeValue = 'Individual Provider', a specific Vlocity State Model configured for Application__c object will be used. |
|
A map object that contains |
|
Required. String value
|
|
Format: HH:MM, military time. Not required if
|
|
String value. Acceptable values: Days can also be
represented numerically, from 1 to 7, where Sunday = Required if
|
Input JSON
Here's an example of the input JSON whose schedule pattern is weekly at 13:30 every Monday:
{
"objectName":"prefix__Application__c",
"fieldName":"prefix__Status__c",
"fromState":"New",
"toState":"Submitted",
"schedule":{
"pattern":"WEEKLY",
"startTime":"13:30",
"dayOfTheWeek":"MON"
}
}Output JSON
The output JSON shows the number of records updated (maximum five) and lists any exceptions.
{
"noOfRecordsForProcessing": <Number of records for processing from a search, max=5>,
"noOfUpdatedRecords": <Number of records that have successful 'from state' to 'to state' transition>,
"noOfUpdatedRecordsToAlternateStates": <Number of records that have successful 'from state' to 'alternate state' transition>,
"errors":<Consolidated error mapping between record ID and error detail. This is null when there's no error.>
}
