Vlocity Facts #32 || Edit Block for Default Actions in OmniScript

An Edit Block element in Omniscript allows the user to create, edit, and delete multiple records. To accomplish this, the edit blocks are repeatable blocks by default. We can configure Edit Block in 3 Ways

  • Adding Default Actions
  • Adding Custom Actions
  • Adding Global Actions

Adding Default Actions  Let us see an example to use an Edit Block in Omniscript to handle multiple records.

In our example, we will use an Edit Block to display the existing Cases linked to an Account and Contact also edit cases directly from the Edit Block.

In the Omniscript, a new DataRaptor Extract Action is added.

Here, 'ExtractCases' is the DataRaptor Extract that retrieves 3 Cases, Limit is 3.
Now a Step element is added to the Omniscript, and an Edit Block is added inside the step.
You can select the actions you need to perform from edit block by enabling those check boxes near to the actions. In this scenario I'm choosing Allow Edit check box to perform edit operations.
From the ‘Properties’ section of the Id and ContactId elements, click Edit Properties As JSON and set the hide property to true. This ensures that the elements don’t show up in the Edit block UI. They will only be used for backend field mapping.
"hide"true,  

‘Edit’ Remote Action: This updates an existing record from the Edit Block. 

Name: Cases-Edit

Field Label: Edit
Remote Class: DefaultOmniscriptEditBlock 
Remote Method: edit. This points to the ‘edit’ method in the ‘DefaultOmniscriptEditBlock’ apex class to update an existing record from the Edit Block.

In the ‘SObject Field Mapping’ section, select the object in which you want to perform the DML operations. In our example, ‘Case is the SObject.

Now click ‘Add SObject Field Mapping’ and map the edit block elements to the corresponding field in the SObject.

OutPut:

Same way we can configure other 2 actions New and delete
.
For New Action follow these steps.
Drag one more Remote Action into edit block and name it according to your requirement.
  • Name: Cases-New

  • Field LabelNew

  • Remote Class: DefaultOmniscriptNewBlock 

  • Remote Methodnew. This points to the ‘new’ method in the ‘DefaultOmniscriptNewBlock’ apex class to update an existing record from the Edit Block.

For Delete Action follow these steps.Drag one more Remote Action into edit block and name it according to your requirement.
  • NameCases-Delete

  • Field Label: Delete

  • Remote ClassDefaultOmniscriptDeleteBlock 

  • Remote Methoddelete. This points to the ‘delete’ method in the ‘DefaultOmniscripDeleteBlock’ apex class to update an existing record from the Edit Block.

Comments

Popular posts from this blog

Vlocity Facts #01 | OmniStudio DataRaptors

Vlocity Facts #34 || Getting the details from the URL in a FlexCard and an Omniscript

Vlocity Facts #44 || Communication between Omniscript and Flexcard [Pub/Sub]