SK SKYVVA Documentation

How to Pass parameter from InvokeCalloutV3() to use in the WHERE clause expression?

Introduction

We have such a feature that the user can pass and condition parameters to fill in their query in outbound runtime.

In this feature, we can see all the conditions as pretty much as an old feature that we have, the condition appends in runtime without a monitor or any note for the user. Moreover, this feature makes it easy for users to read the query with all their conditions.

This feature has a few key characteristics:

Overall, this feature provides flexibility and control to users, allowing them to adapt their queries in real-time without the need for constant monitoring instructions. It's designed to empower users to work with their data effectively and read and understand the queries with their unique conditions.

Runtime Query :

|DEBUG|>query_step: SELECT Id, BillingCity, Name, Description, BillingCountry FROM Account WHERE ((Id IN: ids)) AND (Name = 'Vireak' AND (BillingCity='Takeo' OR BillingCity='PhnomPenh'))

We see only in the debugging mode and that is not user-friendly. Here is another example.

Here is another case result:

|DEBUG|>query_step: SELECT Id, BillingCity, Name, Description, BillingCountry FROM Account WHERE (Name = 'Vireak' AND (BillingCity='Takeo' OR BillingCity='PhnomPenh')) AND (Id IN: ids)

This example shows that we can append our expression passing from the invokeCalloutV3() with the customer expression. However, we cannot mix the parameter from the invokeCalloutV3() with the customer expression. That is not possible with the current solution. When we change the idea to allow the user to use the parameter name in their expression then it is more flexible, and we can read and understand the WHERE clause.

Pass parameter from InvokeCalloutV3() to use in the WHERE clause expression

Creating an interface outbound for passing parameters from the InvokeCallOutV3() function to use in a WHERE clause expression. Here are some general steps you might follow to achieve this:

Here are some key points to consider when implementing such a feature:

[su_box title="Expectation: " box_color="#2a8af0" title_color="#000000"]We will allow the user can pass and conditions parameter to fill in their query condition in outbound runtime. In this feature, we can add all the conditions as pretty much as an old feature that has the conditions appended in runtime without a monitor or any note for the user. Moreover, this feature is also easy for users when they read the query with all their conditions.[/su_box]

Required step:

Example: MyField = {!MyFieldValue}

We added {!AccountName} expression parameter on field Name on where clause

 

[su_box title="Note" box_color="#2a8af0" title_color="#000000"] Please replace on integration with your integration name and interface to your interface name[/su_box]

Map<String,String> p = new Map<String,String>(); p.put('AccountName','University of Arizona'); skyvvasolutions.CallOutControl c = new skyvvasolutions.CallOutControl(); c.sqlWhereExpression = p; //parameter to replace query {!XXX} c.returnJSONComplete=true; //return json result in SYNC c.actionDoIntegrate=false; //skip execute response interface c.isCreateMessage=true; //create message for each execute String[] ids = new String[]{}; for(Account a: [select id from account]) ids.add(a.Id); String integration = 'Minea_Intergration'; String interfac = 'InvokeCallOutV3'; String mode = 'SYNC'; List<skyvvasolutions.CalloutResponse> resp = skyvvasolutions.Iservices.invokeCalloutV3(integration,interfac,ids,mode,c); System.debug('>>resp:'+resp?.toString());

Example:

[su_box title="Result: " box_color="#2a8af0" title_color="#000000"]After Executing the Apex Code, it will check all Accounts have Name = “University of Arizona” to send the record out.[/su_box]

Example: MyfieldNumber = {!@mynumber}

We added {!@NumberofLocations} expression parameter on field NumberofLocations on where clause

Example:

Map<String,String> p = new Map<String,String>(); p.put('NumberOfLocations','955'); skyvvasolutions.CallOutControl c = new skyvvasolutions.CallOutControl(); c.sqlWhereExpression = p; //parameter to replace query {!XXX} c.returnJSONComplete=true; //return json result in SYNC c.actionDoIntegrate=false; //skip execute response interface c.isCreateMessage=true; //create message for each execute String[] ids = new String[]{}; for(Account a: [select id from account]) ids.add(a.Id); String integration = 'Minea_Integration'; String interfac = 'InvokeCallOutV3'; String mode = 'SYNC'; List<skyvvasolutions.CalloutResponse> resp = skyvvasolutions.Iservices.invokeCalloutV3(integration,interfac,ids,mode,c); System.debug('>>resp:'+resp?.toString());

[su_box title="Result: " box_color="#2a8af0" title_color="#000000"]After Executing the Apex Code, it will check all Accounts have NumberOfLocations = 955 to send the record out.[/su_box]

Example: MyfieldNumber IN {!@mynumber}  (we can CallOut by real value many records)

We added IN {!@NumberofLocations} expression parameter on field NumberofLocations on where clause

Example:

Map<String,String> p = new Map<String,String>(); p.put('NumberOfLocations','(1,2,3)'); skyvvasolutions.CallOutControl c = new skyvvasolutions.CallOutControl(); c.sqlWhereExpression = p; //parameter to replace query {!XXX} c.returnJSONComplete=true; //return json result in SYNC c.actionDoIntegrate=false; //skip execute response interface c.isCreateMessage=true; //create message for each execute String[] ids = new String[]{}; for(Account a: [select id from account]) ids.add(a.Id); String integration = 'Minea_Integration'; String interfac = 'InvokeCallOutV3'; String mode = 'SYNC'; List<skyvvasolutions.CalloutResponse> resp = skyvvasolutions.Iservices.invokeCalloutV3(integration,interfac,ids,mode,c); System.debug('>>resp:'+resp?.toString());

[su_box title="Result" box_color="#2a8af0" title_color="#000000"]After Executing the Apex Code, it will check all Accounts have NumberOfLocations IN (1,2,3) to send the record out.[/su_box]

Example: SLA IN {!@colectionAsString} (value passed as String of collection)

We added IN {!@SLA } expression parameter on field SLA on where clause (SLA field type is PickList)

   Example:

List<String> customSLA = new List{'Silver','Platinum','Bronze'}; Map<String,String> p = new Map<String,String>(); String typeSLA = '(\''+String.join(customSLA,'\',\'')+'\')'; p.put('SLA',typeSLA); skyvvasolutions.CallOutControl c = new skyvvasolutions.CallOutControl(); c.sqlWhereExpression = p; //parameter to replace query {!XXX} c.returnJSONComplete=true; //return json result in SYNC c.actionDoIntegrate=false; //skip execute response interface c.isCreateMessage=true; //create message for each execute String[] ids = new String[]{}; for(Account a: [select id from account]) ids.add(a.Id); String integration = 'Minea_Integration'; String interfac = 'InvokeCallOutV3'; String mode = 'SYNC'; List resp = skyvvasolutions.Iservices.invokeCalloutV3(integration,interfac,ids,mode,c); System.debug('>>resp:'+resp?.toString());

[su_box title="Result:" box_color="#2a8af0" title_color="#000000"]After Executing Apex Code, it will check all Accounts have SLA IN ('Silver', 'Platinum', 'Bronze') to send the record out.[/su_box]

[su_box title="Note" box_color="#dcdcdc" title_color="#000000"]

for the child “Account.Id IN: ids” g (User’s conditions….) AND (Our condition) SELECT Name, BillingCity FROM Account WHERE (Name = ‘MyAccount’) AND (Id IN: ids)

[/su_box]

[su_box title="Result: " box_color="#2a8af0" title_color="#000000"]It means all conditions defined must be matched with the passed records Id from invokeCalloutV3()[/su_box]

Summary

The feature in question allows users to pass parameters from the InvokeCalloutV3() function and use them in the WHERE clause expression of their queries. This feature enhances flexibility and control, enabling users to dynamically adjust their queries without requiring ongoing monitoring or specific instructions. Its primary purpose is to empower users to work efficiently with their data, enabling them to create and comprehend queries with unique conditions.

Open this article in the interactive viewer →