top of page
OmniStudioFactBg.png
Search

Using SOQL Query in DataRaptor Formula

  • Writer: Palem Ravi Kiran Reddy
    Palem Ravi Kiran Reddy
  • May 2, 2023
  • 1 min read

We can execute a SOQL query in the Dataraptor formula by using the QUERY function. But it can only retrieve up to one column. Let's see a few examples of using it:

  • Passing a static value

QUERY ("SELECT Name FROM Account WHERE BillingState ='CA'")
  • Querying with a single dynamic value

QUERY( "SELECT AccountId FROM User WHERE Id = '{0}'",$Vlocity.UserId )

  • Querying with multiple dynamic values

QUERY ( "SELECT Id FROM Account WHERE RecordType.DeveloperName = 'Member' And LastName Like '{0}' And FirstName Like '{1}' And DateOfBirth__pc = {2} And Phone = '{3}' ", lastNameToSearch, firstNameToSearch, formattedDate, Phone)

  • Similarly, we have a CountQuery function that returns the number of records returned

	COUNTQUERY ( "SELECT COUNT() FROM Case WHERE AccountId = '{0}'" , Id)



Considerations :

1. To use the Like operator in the query we have to form the string in the below format and use this concatenated value in the Query.

ree

2. To Query with the date field, the dynamic notation should not have quotes i.e., instead of ‘{1}’ use {1}. For example, DateOfBirth__pc = {1}


ree


References:


 
 
 

Recent Posts

See All
OmniscriptBaseMixin Methods

Enable a custom Lightning web component to interact with OmniScript by extending the OmniScriptBaseMixin component. The...

 
 
 
OmniStudioFactFooterBg.png
logo.png

OmniStudiofacts helps us to build a Vlocity/OmniStudio Tech Community which focuses on sharing technical skills and experience across the globe.

© 2023 by OmniStudioFacts.

bottom of page