Documents
HomeAcademyContactInstallation Guide
User Manual
User Manual
  • Introduction & High Level Architecture
  • 200 OK Versions
    • Prerequisites
      • Internal Authentication Setup
      • Configuration for Email Threshold
    • Release Notes 200 OK Version 5.68.0
    • Release Notes 200 OK Version 5.36.0
    • Release Notes 200 OK Version 5.0.0
    • Release Notes 200 OK Version 4.26.0
    • Release Notes 200 OK Version 4.22.0
    • Release Notes 200 OK Version 4.6.0
    • Release Notes 200 OK Version 4.1.0
    • Release Notes 200 OK Version 3.47.0
    • Release Notes 200 OK Version 3.41.0
  • 200 OK UI Walkthrough
  • Access Configuration
  • Integration Channel
    • How to Create an Integration Channel.
    • Run Your Integration Channel: Let’s Make It Happen!
  • Integration Actions
    • Data Store
    • sObject
    • Apex Class
    • File
    • Platform Event
    • Quick Action
    • Global Action
    • Big Object
    • External Object
    • Integration Channel
    • Auto-launched Flow
    • Callback (client callback)
    • Custom Settings
    • Custom Metadata Type
    • Custom Label
    • Push Notification
  • ETL
    • Create Your ETL
      • Data Source
      • Transform
      • Load
      • Additional Features of ETL
  • Webhook
    • Setting Up Your Webhook!
    • Create Your Webhook!
    • Putting Your Webhook to the Test!
  • Invoke Integration Channel
    • Flow into Action: Invoking Your Integration Channel!
    • Unleash the Power: Invoke with Apex!
  • LWS
    • Transform Data on Demand: ETL as an API!
    • Supercharge Your Workflow: Invoke Integration Channel via API!
  • Built-in Functions
    • Text
      • getChar
      • extract
      • proper
      • len
      • trim
      • rightPad
      • leftPad
      • left
      • right
      • mid
      • getCharIndex
      • coalesce
      • toBoolean
      • toDecimal
      • split
      • replace
      • remove
      • toLowerCase
      • ascii
      • begins
      • capitalize
      • contains
      • deDuplicate
      • escapeHtml
      • generateRandomString
      • getValueFromResponseHeader
      • join
      • reverse
      • startCase
      • stripHtml
      • toBinaryBase64
      • toInt
      • toString
      • toUpperCase
      • escapeMarkDown
    • Math
      • abs
      • acos
      • asin
      • average
      • base64Decode
      • base64Encode
      • ceil
      • generateRandom
      • max
      • min
      • parseNumber
      • round
      • sum
      • switch
      • floor
    • Date & Time
      • toSeconds
      • daysBetween
      • dayPrecision
      • setHour
      • daysInMonth
      • dateTimeNow
      • netWorkDays
      • dateAdd
      • dateDiff
      • addMonths
      • date
      • dateTimeValue
      • dateValue
      • day
      • dayofYear
      • formatDate
      • formatDateToday
      • formatDateTodayFormat
      • formatDateTodayUnix
      • formatDateUnix
      • formatDateUnixFormat
      • toTime
      • toDate
      • toDateTime
      • toDateTimeUnix
    • Advanced
      • generateUUID
      • uncompress
      • compress
      • exists
      • dwTransform
      • discard
      • currencyRate
      • decodeUrl
      • encodeUrl
      • getChannelData
      • getLink
      • invokeFlow
      • invokeETL
      • lookup
      • md5
      • sha1
      • sha256
      • sha512
      • toJson
    • Logical
      • and
      • blankValue
      • case
      • if
      • isBlank
      • isNull
      • isNumber
      • not
      • nullValue
      • or
  • Custom Function
  • Filters for Integration Action
  • Data Mapping Types
    • Key/Value
    • JSON
  • Global variables for Data Mapping
    • Index
    • Record field
    • User
    • Organization
    • Custom Settings
    • Custom Metadata Type(MDT)
  • Advance Setting
  • Schedule
  • Utilities
    • Add Remote Site
    • Json To Apex
    • JSON parser invocable method
    • Export/Import Functionality
    • Import from Postman
    • Curl Import
    • Apex Class Template Creation for Header, Request and Response.
  • Logging
  • Monitor
    • Measure and track the usage
    • Integration channel (total active channels)
    • Callouts (total monthly callouts)
  • Most frequently used scenarios
    • Efficient Bulk Data Handling Using "!index"
    • How to access authentication data from a custom setting?
    • How to set up auth provider and named credentials?
    • How to use named credentials in an integration channel?
    • How to invoke integration channels from flow?
      • Screen flow
      • Record trigger flow
      • Platform event
      • Scheduled flow
    • How to set up a quick action with the integration channel flow?
Powered by GitBook
On this page

Custom Function

A custom function in the 200 OK application allows users to define their own logic using the interface provided within the Apex environment. This empowers users to tailor the application to their specific needs, incorporating custom business logics, and data processing operations seamlessly into their processes. Below is the sample class for creating your own Custom Function Apex Class: global class CustomDateTimeFormatter implements lwapic.IICCallableService {

global Object call(String action, Map<String, Object> params) {

Object dataToReturn = new Map<String, Object>();

if (action.equalsIgnoreCase('fx_formatDateTime')) {

dataToReturn = formatDateTime(params);

}

return dataToReturn;

} private Object formatDateTime(Map<String, Object> params) {

List<Object> paramList = (List<Object>) params.get('input');

String dateTimeString = String.valueOf(paramList.get(0));

Integer year = Integer.valueOf(dateTimeString.substring(0, 4));

Integer month = Integer.valueOf(dateTimeString.substring(5, 7));

Integer day = Integer.valueOf(dateTimeString.substring(8, 10));

Integer hour = Integer.valueOf(dateTimeString.substring(11, 13));

Integer minute = Integer.valueOf(dateTimeString.substring(14, 16));

Integer second = Integer.valueOf(dateTimeString.substring(17, 19));

Datetime formattedDateTime = Datetime.newInstanceGmt(year, month, day, hour, minute, second);

Map<String, Object> resultMap = new Map<String, Object>();

resultMap.put('result', formattedDateTime);

return resultMap;

}

} *Note :- 1. When implementing a custom class using this interface, we must use a global access modifier. The lwapic.IICCallableService interface includes a method named call, which accepts two inputs: "string" and "map"(containing a string and an object). 2. In the CustomDateTimeFormatter class, we implement the lwapic.IICCallableService interface. 3. The call method checks the action parameter to determine the specific action to perform. If the action is fx_formatDateTime, it calls the formatDateTime method. 4. This method extracts a datetime string from the input map, parses it, and constructs a datetime object. The formatted datetime is then returned in a map with the key 'result'.

Test Class: @isTest

private class CustomDateTimeFormatterTest {

@isTest

static void testCustomDateTime() {

CustomDateTimeFormatter formatter = new CustomDateTimeFormatter();

String action = 'fx_formatDateTime';

Map<String, Object> params = new Map<String, Object>();

List<Object> inputParams = new List<Object>{'2024-02-21 09:58:57'};

params.put('input', inputParams);

Object result = formatter.call(action, params);

Map<String, Object> resultMap = (Map<String, Object>) result;

Datetime formattedDateTime = (Datetime) resultMap.get('result');

System.assertEquals(2024, formattedDateTime.year());

System.assertEquals(2, formattedDateTime.month());

System.assertEquals(21, formattedDateTime.day());

}

} How to use Custom Function in the Action Syntax :- Class:fx_methodName(/path)

Example :- CustomDateTimeFormatter:fx_formatDateTime(/StartDate) In the value side, you can use the above syntax to set the value accordingly.

PreviousorNextFilters for Integration Action

Last updated 1 year ago