Showing posts with label Function. Show all posts
Showing posts with label Function. Show all posts

Saturday, May 25, 2024

Function for Deleting Declare Pages in Pega

Managing declare pages in Pega is crucial for ensuring optimal performance and maintaining data integrity. Sometimes, you may need to delete all instances of a declarative page, especially during troubleshooting or system maintenance. Pega provides an out-of-the-box (OOTB) function to achieve this efficiently. In this blog post, we will explore how to delete all declare pages using the pzDeleteAllInstancesOfDeclarativePage function in Pega.

The Function to Delete Declare Pages

The function @(Pega-RULES:DeclarePages).pzDeleteAllInstancesOfDeclarativePage(tools, DataPageName) allows you to delete all instances of a specified declarative page. This function is powerful and should be used with caution to avoid unintended data loss.

Parameters:

  • tools: The standard tools parameter used in activities.
  • DataPageName: The name of the declarative data page you want to delete.

Example

Suppose we have a declarative page named D_CustomerData. To delete all instances of this declarative page, the function call in the Data Transform will look like this:

  • Function: @(Pega-RULES:DeclarePages).pzDeleteAllInstancesOfDeclarativePage(tools, "D_CustomerData")

Conclusion

Deleting all instances of a declarative page can be a powerful tool for managing your Pega application's data. By using the pzDeleteAllInstancesOfDeclarativePage function, you can easily perform this task within a Data Transform. Remember to use this function judiciously to avoid unintended data loss.

Happy Pega development! 😁


Further Reading

Logging Messages in Pega Using Data Transforms

Pega offers a set of out-of-the-box (OOTB) functions to log messages at different levels in the Pega logs. This can be incredibly useful for debugging and monitoring the behavior of your applications. In this post, we'll explore how to log messages through Data Transforms in Pega, specifying the desired log level.

Available Logging Functions

Pega provides two main functions that you can use in Data Transforms to log messages:

  1. @Default.pxLogMessage(sMessage): Logs the message at the error level.
  2. @Default.pxLogMessage(sMessage, cLevel): Logs the message at a specified level.

Parameters:

  • sMessage: The message you want to log.
  • cLevel: The log level, indicated by a single character:
    • d – debug
    • i – info
    • f – info forced
    • w – warn
    • e – error

Viewing Log Messages

To view the log messages in Pega Dev Studio, navigate to:


Dev Studio > Configure > System > Operations > Logs > Log files > PegaRULES.Log

Example Usage

Let's look at how to log a message as info forced and error using Data Transforms.

Log a Message as InfoForced

To log a message as info forced, use the following syntax in your Data Transform:


@(Pega-RULES:Default).pxLogMessage(param.Message, 'f')

Log a Message as Error

To log a message as error, use the following syntax in your Data Transform:


@(Pega-RULES:Default).pxLogMessage(param.Message, 'e')

Conclusion

Using these OOTB functions to log messages at different levels in Pega is straightforward and powerful for tracking the behavior and issues in your application. Happy logging!


Sunday, June 18, 2023

CSV format string from a Pagelist

In our business logic often we have the requirement to convert PageList to string CSV values.


From - 

PageList.pxResults(1).pyLabel  = P1

PageList.pxResults(2).pyLabel  = P2 

PageList.pxResults(3).pyLabel  = P3


To – "P1","P2","P3"


We need to convert this above page list to a comma-separated value.

There are many ways to achieve this. but the easiest way to do this using an OOTB function 


@pxDataManipulate.pxStringCSVFromPageList

@pxDataManipulate.pxStringCSVFromPageList(PageList,".PropertyName")

This function takes 2 parameters.


pageList - PageList that needs to be iterated

propertyName - property whose CSV is needed


e.g 

@pxDataManipulate.pxStringCSVFromPageList(PageList.pxResults,".pyLabel")

In the above function 


PageList.pxResults - Page List 

.pyLabel - Name of the property whose CSV is needed 








Saturday, September 3, 2022

Convert comma-separated String CSV to Pagelist

 In our business logic often we have the requirement to convert the string CSV value to a page list.

E.g – Apple,Orange,Banana,Mango,Grapes

We need to convert this above string comma-separated value to page list

There are many ways to achieve this. but the easiest way to do this using an OOTB function 

@(Pega-Gadgets:pxDataManipulate).pxPageListFromStringCSV

This function takes 4 parameters.



stringCSV

inputPagelist

property

pageClass

Let's see how to use the same

@(Pega-Gadgets:pxDataManipulate).pxPageListFromStringCSV(Param.CsvValue,.pxResults,".pyName","PO-Demo-Work-APlusInsurance")

In the above example Param.CsvValue contains comma separated CSV values.

pxResults is the pagelist name  

pyName - Property name to hold the value

PO-Demo-Work-APlusInsurance - Pagelist Class





 


 

     





Featured post

Queue Processor

  Overview Starting with Pega Platform version 8.1, Job Scheduler and Queue Processor rules replace Agents and improve background processi...

Popular Posts