Create a Remote Action in an Omniscript


GitHub: Create a Remote Action in an Omniscript


This post is about how to create a Remote Action in a Omniscript. We can create a difficult logic in Apex and call our method from a Remote Action in Vlocity. In this example, this omniscript is an account form which creates an account record with a Remote Action.


Step 1. Create the Apex class

Step 2. Create the omniscript form

Step 1. Create the Apex class

Create the apex class to insert the account record. The code is in the GitHub link on the top. The methods are:

  • invokeMethod(String methodName, Map<String,Object> inputMap, Map<String,Object> outMap, Map<String,Object> options): method that allow to us to call an apex class with Vlocity.
  • setVariables(String methodNameParam, Map<String,Object> options): set the private variables in the class.
    • methodNameParam: method which we invoke. Receive the ‘methodName’ variable from the invoke method.
    • options: receive the options params from the invoke method. In this example, only the ‘accountName’.
  • isAccountNameOption(String optionKey): return true if the option is ‘accountName’.
  • isInsertAccountMethod(): return true if the method is ‘insertAccount’. This method is called from an if statement to avoid executing this action if it is set the method name.
  • insertAccount(): insert the account record.

Step 2. Create the omniscript form

Open ‘Vlocity OmniScript Designer’ tab and click on ‘New’ button. Fill the fields with the following values and click on ‘Save’.Screen Shot 2018-11-07 at 18.08.18

Drag and drop a ‘Step’ group.

Screen Shot 2018-11-07 at 18.10.37

Drag and drop a ‘Text’ input to the account name field.

Screen Shot 2018-11-07 at 18.13.44

Drag and drop a ‘Remote Action’. This element gets the account name from the form and send the variables to the apex class which was created before.  We have to pay attention when we set all the variables.

Screen Shot 2018-11-07 at 18.15.46

Drag and drop a ‘Step’ group.

Screen Shot 2018-11-07 at 18.22.11

Drag and drop a ‘Text block’ and write the success message.

Screen Shot 2018-11-07 at 18.20.32

Click on ‘Preview’ tab to test it. Fill the ‘Account Name’ field and click on ‘Next’.

Screen Shot 2018-11-07 at 18.23.10

We will be redirected to the success page.

Screen Shot 2018-11-07 at 18.24.00

Go to the ‘Account’ tab and check the record was created.Screen Shot 2018-11-07 at 18.26.32

14 thoughts on “Create a Remote Action in an Omniscript

  1. Hello,

    I wanted to know if theres any vlocity org for practice as i am a fresher so i need to practice on that org.


    1. Hi Simran,

      You can visit vlocity website and contact with the support team if it is possible to download the vlocity package for training purpose.



  2. I am new to vlocity, where can i find use cases like these for practise, and also how can i find solutions/ suggestions if i stuck in between while working on use case. no info is available outside


    1. Hi Tejas,

      Unfortunatedly, as you said there are not plenty of information about vlocity. This is one of the reason I wrote some posts about this. If you ask vlocity, they can give you some training plans and vlocity supoort team can ask you some questions. However, you have to pay for that.

      Good luck!


  3. For creating record we are already having dataraptor post action but instead we are using remote. why? what is the difference of using apex instead of dataraptor


    1. Hi vamsi,

      There are plenty of reasons but I can give you the main ones. If you use Dataraptors, the user interface is easier to understand than the code and you can skip to do apex test classes. However, if a complex logic is required to fill the fields, the you should play with Omniscripts and Apex

      Enjoy learning Salesforce and Vlocity!


  4. Hello Ignacio Sarmiento Losada,

    I saw your example OmniScript Designer. I have requirement like we have added Step in designer and didnt give any text to Step. Now in Preview it shows horizontal line at the top. We want to hide that or remove but want step as well. Can you please help in any CSS or JavaScript kind of code.


    1. Hi Harshad,

      Thanks for your question. I recommend not to update the CSS or Javascript because can cause some bugs. You should use Vlocity out of the box functionality. If you don’t find a way, you can contact with Vlocity support and they might give you some Vlocity templates to update it.



  5. Hello Ignacio Sarmiento Losada,

    I had a question. Once we have created a omniscript, how to invoke it from the Account record type? I have created an omniscript to be able to add products on to the cart but I am not sure how I can invoke it from an Account or Opportunity record type?


    1. Hello Steve,

      Thanks for your question. You can do it in 2 ways:
      a) Dataraptor + Omniscript: you can query the record type in the DataRaptor and link this Dataraptor with with your Omniscript
      b) Remote Actions + Omniscript: you can query it with apex and return the Id to your Omniscript

      I would recommend the a) option to try to reduce the created code in apex.



  6. Hi,

    Can you please briefly, tell me about the role of Ominiscript in Vlocity and what is Ominiscript? Is it a programing language like java-script?


  7. Hi, good post, is there any way to send a DataRaptor Transform Action response into a remote action? In that case, how I pass the JSON to the apex class? Using the SEND/RESPONSE TRANSFORMATIONS? I tried it, but I receive a null value and if I try to pass via options or ADDITIONAL INPUT/OUTPUT/FAILURE RESPONSE receive a null. I made a test sending a hardcode value and receive well. Any help?


    1. Hi victorforce,

      Thanks for your message.

      I am not pretty sure if they are a DataRaptor Transform Action for that. You can take look to the Vlocity docs to see if it is possible.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s