Thursday, November 28, 2019

How to call Rule Utility Function (RUF) from other Rule Utility Function (RUF)

Rule Utility Function (RUF) is very flexible and useful for writing reusable code which can be assembled (generated and compiled) once, and can be used across applications.

This post talks about how to call Rule Utility Function of a library from Rule Utility Function of other library. For example: a developer has a scenario where it should call FormatDateTime RUF from their own RUF (function):

FomatDateTime Rule Utility Function: 

Objective: This is pega provided OOTB function to format the date time.
Ruleset Name : Pega-RULES
Library Name : DateTime
Function Name : FormatDateTime
Parameters : 4 parameters as highlighted in below screenshot

Our RUF which should invoke the above FormatDateTime Rule Utility function:

Objective: We can use this function to call OOTB formatDateTime function.
Ruleset Name : Give your own ruleset name
Library Name : Give your own library name
Function Name : Give your own function name
Parameters : Date (depends on your scenario, for example taken date here for simplicity)


Syntax for invoking RUF from other RUF is : RulesetName_LibraryName.FunctionName
In this example, it is : pega_rules_datetime.FormatDateTime


  • If ruleset has hyphen( - ) in between that should be substituted with underscore ( _ )
  • Parameters count and type should match with the function (in this case, all the four parameters are passed as shown below)
  • Library Name and ruleset name to be converted to lower case
  • If function you are planning to invoke is in the same library, directly you can invoke using function name instead of above syntax.

This way, we have called FormatDateTime function from own function. Likewise we can call any function from other function.

Post Credits: Sandeep

I hope this is helpful, if there are any comments feel free post here.  Happy learning. Thanks.

1 comment:

HowToPega : All rights reserved and the contents are copyrighted to Pavan Kumar Naidu