Display Files from a Server Path in Pega Using an Activity and Java Step

 In some enterprise applications, you may need to display the list of files and folders available in a server directory directly inside a Pega application. This can be useful for:

  • Monitoring batch file drops
  • Viewing integration files
  • Validating document uploads
  • Supporting admin utilities
  • Troubleshooting file-processing jobs

This article explains how to create a Pega Activity that reads files from a server directory using Java and stores the results into a Page List for UI display or further processing.

Use Case

The requirement is simple:

Read all files and folders from a server directory and display:

  • File name
  • Folder name
  • File size
  • File creation date/time

The solution uses:

  • A Pega Activity
  • Java Step
  • Code-Pega-List
  • pxResults
  • Java File APIs

To display the files in the server path Create Activity and add these steps
Java used for this activity
try { 
  ClipboardPage PLPage = tools.createPage("Code-Pega-List" , "");
  ClipboardPage ResultPage = tools.createPage("Data-", "");
   oLog.infoForced("[FilesInDirectory] try block started "); 

		java.io.File fileContents[] = new java.io.File(Directory).listFiles();
		if (fileContents != null) {
			for (int i = 0; i < fileContents.length; i++) {
				   if(fileContents[i].isDirectory())
        {
            ResultPage.putString ("pyLabel", "[FilesInDirectory] Folder: "+fileContents[i]);
tools.findPage("PLPage").getProperty("pxResults").add(ResultPage);

          oLog.infoForced("[FilesInDirectory] Folder: "+fileContents[i]); 
        }
				 else
         {
           //long fileSize = fileContents[i].length();
           ResultPage.putString ("pyLabel", "[FilesInDirectory] File: "+fileContents[i]);
           ResultPage.putString ("pyNote", "[FilesInDirectory] size(bytes): "+fileContents[i].length());
           
           
           // Getting the file creation datetime
 java.nio.file.Path filePath = fileContents[i].toPath();
 java.nio.file.attribute.BasicFileAttributes attrs = java.nio.file.Files.readAttributes(filePath, java.nio.file.attribute.BasicFileAttributes.class);
      java.nio.file.attribute.FileTime creationTime = attrs.creationTime();
             
         // Adding the creation time to the ResultPage
        ResultPage.putString("TempSelectedEffectiveDate", "[FilesInDirectory] Creation Time: " + creationTime.toString());
           
           

        tools.findPage("PLPage").getProperty("pxResults").add(ResultPage);
           oLog.infoForced("[FilesInDirectory] File: "+fileContents[i]);
         }
				}
			}   
  oLog.infoForced("[FilesInDirectory] try block Ended "); 

			
} catch (Exception ex) { 
	oLog.error("[FilesInDirectory] catch block expected", ex);
}

Download files From the Server Path in Pega

In many Pega applications, there are scenarios where files are generated dynamically and stored temporarily on the server. Users may then need to download these files directly from the application UI. One practical approach is to create a custom Activity that reads the file from the server path and streams it to the browser for download.


This blog explains how to implement file download functionality in Pega using Java steps inside an Activity.

Use Case

Suppose your application:

  • Generates PDF reports
  • Creates Excel exports
  • Produces temporary documents on the server
  • Stores files in a shared directory

You can allow users to download these files directly using a Pega Activity.


Solution Overview

The implementation works as follows:

  1. Pass the server file path as a parameter
  2. Read the file from the server
  3. Convert the file into a byte array
  4. Use tools.sendFile() to stream the file to the browser
  5. Optionally delete the file after download

Add a Java Step

Add a Java step inside the Activity and use the following code

Java used for this activity

``` //Get the byte array from the parameter page
//String Stream=tools.getParamValue("FileStream");
FilePath = tools.getParamValue("FilePath");
//byte[] byteArray=Base64Util.decodeToByteArray(Stream);


java.io.File originalFile = new java.io.File(FilePath);
java.io.FileInputStream fileInputStreamReader=null;
byte[] bytes=null;
try{
if(originalFile.exists())
  {

         fileInputStreamReader = new java.io.FileInputStream(originalFile);
        bytes = new byte[(int)originalFile.length()];
   fileInputStreamReader.read(bytes);
fileInputStreamReader.close();
}
  else{
    ErrMsg="Uanble to open a file/file dooesn't exist:"+FilePath;
  }
}

catch(Exception ex){
  oLog.error("Error during opening the document in ProcessAutoCreateDocument activity:"+ex.getMessage());
  ErrMsg=ex.getMessage();
}
//Get the file name from the parameter page
pdfName=tools.getParamValue("FileName");


// download the file directly
String result=tools.sendFile( bytes,pdfName,false,null,true);
// delete file from path after download
//originalFile.delete();

Previous Business Date With Australia Day Light saving Logic

 
This post contains logic related to find the previous business day using the Data transform based on the calendar which is passed .




Extracted Table

#ActionTargetRelationSource
1SetParam.DateAESTequal to@DateTime.FormatDateTime(@DateTime.addToDate(@CurrentDateTime(),'0','0','0','0','0','0'),'yyyyMMdd','Australia/Sydney','en_AU')
2SetParam.PreviousBusinessDayAESTequal to@addDays(Param.DateAEST,-1,true,'AUDefault')
3SetParam.DateGMTequal to@CurrentDate('yyyyMMdd','GMT')
4SetParam.PreviousBusinessDayGMTequal to@addDays(Param.DateGMT,-1,true,'AUDefault')
5SetParam.DaylightSavingequal to@InDaylightSaving('Australia/NSW',@CurrentDateTime())
6When@CompareDates(Param.DateAEST,Param.DateGMT)
6.1When@equalsIgnoreCase(Param.DaylightSaving,true)
6.1.1Setparam.StartDateequal to@addToDate(Param.DateGMT,'',13,'','')
6.1.2SetParam.PreviousBusinessDayStartDateequal to@addToDate(Param.PreviousBusinessDayGMT,'',13,'','')
6.1.3SetParam.PreviousBusinessDayEndDateequal to@DateTime.addToDate(param.PreviousBusinessDayStartDate,'1','','','')
6.1.4SetParam.PreviousDayequal to@DateTime.addToDate(param.StartDate,'-1','','','')
6.1.5SetParam.CutOffDateequal to@DateTime.addToDate(param.StartDate,'','','','')
6.2Otherwise
6.2.1Setparam.StartDateequal to@addToDate(Param.DateGMT,'',14,'','')
6.2.2SetParam.PreviousBusinessDayStartDateequal to@addToDate(Param.PreviousBusinessDayGMT,'',14,'','')
6.2.3SetParam.PreviousBusinessDayEndDateequal to@DateTime.addToDate(param.PreviousBusinessDayStartDate,'1','','','')
6.2.4SetParam.PreviousDayequal to@DateTime.addToDate(param.StartDate,'-1','','','')
6.2.5SetParam.CutOffDateequal to@DateTime.addToDate(param.StartDate,'','','','')
7When@equalsIgnoreCase(Param.DateAEST,Param.DateGMT)
7.1When@equalsIgnoreCase(Param.DaylightSaving,true)
7.1.1Setparam.StartDateequal to@addToDate(Param.DateGMT,'',11,'','')
7.1.2SetParam.PreviousBusinessDayStartDateequal to@addToDate(Param.PreviousBusinessDayGMT,'',11,'','')
7.1.3SetParam.PreviousBusinessDayEndDateequal to@DateTime.addToDate(param.PreviousBusinessDayStartDate,'1','','','')
7.1.4SetParam.PreviousDayequal to@DateTime.addToDate(param.StartDate,'-1','','','')
7.1.5SetParam.CutOffDateequal to@DateTime.addToDate(param.StartDate,'','','','')
7.2Otherwise
7.2.1Setparam.StartDateequal to@addToDate(Param.DateGMT,'',10,'','')
7.2.2SetParam.PreviousBusinessDayStartDateequal to@addToDate(Param.PreviousBusinessDayGMT,'',10,'','')
7.2.3SetParam.PreviousBusinessDayEndDateequal to@DateTime.addToDate(param.PreviousBusinessDayStartDate,'1','','','')
7.2.4SetParam.PreviousDayequal to@DateTime.addToDate(param.StartDate,'-1','','','')
7.2.5SetParam.CutOffDateequal to@DateTime.addToDate(param.StartDate,'','','','')

Generic Decision Table For Reusable Email Configuration

Email notifications are a critical part of most enterprise applications.
Whether it’s:

  • Case creation alerts
  • Approval notifications
  • SLA escalations
  • Error communications
  • Customer acknowledgements

Applications often require multiple email configurations spread across different flows and activities.

Hardcoding email details directly inside activities or utilities makes maintenance difficult and increases duplication.

A cleaner approach is to centralize email configurations using a reusable Decision Table.

This article explains how to build a Generic Email Decision Table in Pega that can be reused across the application to dynamically configure:

  • Email recipients
  • CC recipients
  • Subject lines
  • Correspondence rules
  • Data transforms

 

Why Use a Generic Email Decision Table?

Without a centralized approach:

  • Email logic becomes duplicated
  • Changes require updates in multiple places
  • Maintenance becomes error-prone
  • Business teams cannot easily manage configurations

Using a Decision Table provides:

  • Centralized email configuration
  • Reusability across applications
  • Easier maintenance
  • Cleaner activities and flows
  • Dynamic email behavior


Solution Overview

We will create a Decision Table named:

SendEmailByPurpose

This decision table will determine which email configuration to use based on a business purpose.

This Post talks about how to create a Generic Email Decision table which can be used across appliation to configure the Email parameters like To , CC , Subject and Body.

Lets Create a Decision table , SendEmailByPurpose

Sample Decision Table Configuration

pyPurposeEvaluatepyDataTransformpyCorrForSendEmailpySubjectpyToEmailString
CASE_CREATEDtruePrepareCaseEmailCaseCreatedCorrCase Created Successfully.CustomerEmailsupport@company.com
APPROVAL_REQUIREDtruePrepareApprovalEmailApprovalCorrApproval Required.ManagerEmailescalation@company.com
PAYMENT_SUCCESStruePreparePaymentEmailPaymentCorrPayment Successful.CustomerEmailfinance@company.com

Input columns in Decision table 

  • pyPurpose → Identifier used to determine which email configuration should be triggered.
  • Evaluate → Condition column using @equals("true", current-value) to validate whether the rule row should be executed.
  • Output columns in Decision table 

    • pyDataTransform → Stores the mapping Data Transform used to prepare email data before sending.
    • pyCorrForSendEmail → Defines the Correspondence rule/template used for the email content.
    • pySubject → Stores the subject line of the email.
    • pyTo → Contains the primary recipient email address(es).
    • EmailString → Contains the CC recipient email address(es). 

      Note: The above properties are sample properties and can also be implemented using custom properties based on your application design standards and business requirements.




    Architecture Benefits

    1. Centralized Email Management -All email configurations exist in one place.


    2. Reduced Hardcoding - Activities remain generic and reusable.
    3. Easier Maintenance - Business changes only require updating decision table rows.
    4. Improved Scalability - Adding a new email type requires:New row/ No code changes
    5. Better Governance - Email configurations become easier to audit and manage.


    Conclusion

    A Generic Email Decision Table is a powerful design pattern in Pega that helps standardize and centralize email notification management across applications.

    By configuring:

    • Recipients
    • Subjects
    • Correspondence rules
    • Data transforms

    in a reusable Decision Table, you can:

    • Reduce duplication
    • Simplify maintenance
    • Improve scalability
    • Build cleaner applications

    The SendEmailByPurpose approach is especially useful in large enterprise applications where multiple email types and workflows need to be managed consistently.


    Constellation Architecture

     Constellation Architecture


    Pega 8.8 version

    if alternate design system



    Make the Right Decision


    Create New Application using Constellation

    Select Cosmos React

    Get My Visa Application Name


    Check the application stack


    Preview the application for error message


    Why Pega is using Constellation ?

     So why Pega is using Constellation ?


    Configuration over customization
    User Friendly Javascript Rendering 
    Decopuled server(s) for UI codebase
    Less Maintenance and smooth upgrade


    Understanding of Kafka

    What is Kafka ?

    Distributed Streaming platform

    Think of it as:
    👉 Producers (send messages) → Kafka Broker (stores/distributes them in Topics) → Consumers (read messages).


    Core Concepts

    1. Broker – A Kafka server that stores and serves messages.

    2. Topic – A logical category to which messages are published (like a folder).

    3. Partition – A topic is split into partitions for scalability. Each partition is an ordered sequence of messages.

    4. Producer – Application that sends messages to a topic.

    5. Consumer – Application that reads messages from a topic.

    6. Consumer Group – A group of consumers that share the load of reading messages from partitions.



    To Understand what value is there in the partition.

    Install KafkaTool and provide the details from tomcat\kafka-1.1.0.8\config\server.config -> listeners line

    ClusterName - Kafka-1.1.0.8
    Kafka Cluster Version - 1.1
    ZookeperHost -> 192.168.4.21
    ZookeperPort -> 9092
    ChrootPath - > /



    I have created a QP - ABCDEF which i can see it has created 6 partitions (0-6)
    Each Partitions has Offset from start 0


    Now simply queue three items to QP
    The Queue items are exeuted and can see the partitions selected  1, 2, 3 and each ran once



    Build a Beautiful Multi Timer Application Using HTML, CSS, and JavaScript

     Timers are useful in many day-to-day scenarios:

    • Study sessions
    • Workout routines
    • Cooking
    • Gaming breaks
    • Productivity tracking
    • Pomodoro sessions

    In this article, we will build a modern Multi Timer Web Application using:

    • HTML
    • CSS
    • JavaScript

    The application allows users to:

    • Create multiple timers
    • Start, pause, and reset timers
    • Delete timers
    • Automatically change timer colors based on remaining time

    Features of the Multi Timer Application

    This timer application includes:

    ✅ Multiple independent timers
    ✅ Dynamic timer creation
    ✅ Start / Pause / Reset functionality
    ✅ Delete timer option
    ✅ Gradient UI design
    ✅ Responsive layout
    ✅ Color-changing alerts based on remaining time
    ✅ Smooth modern styling


    Application Overview

    The UI contains:

    • Timer Name input
    • Minutes input
    • Seconds input
    • Add Timer button

    Each timer card includes:

    • Timer title
    • Countdown display
    • Start button
    • Pause button
    • Reset button
    • Delete button

    Complete Source Code

    HTML Structure

    The HTML creates:

    • Input section
    • Timer container
    • Dynamic timer cards 
    Java used for this activity

    
    
    
    
    
      
      Multi Timer
      
    
    
      

    Go and Play Timer

    -

    Pending Constellation

     

    1. Flexible UI with Constellation - https://community.pega.com/blog/flexible-ui-constellation - Kamil Janeczek
    2. Prescribed and flexible UI with Constellation - https://community.pega.com/blog/prescribed-and-flexible-ui-constellation - Kamil Janeczek
    3. How Constellation works - from authoring to rendering - https://community.pega.com/blog/how-constellation-works-authoring-rendering - Piotr Jurkowski

    Constellation hands on L4

     

    Constellation Building Blocks

    Constellation Architecture is made of several building blocks, which work together in harmony to help you crush complexity.

    Client device

    In traditional Pega UI, server does both the business logic and generating all of the UI markup
    But in constellation , user browsers and devices to do the heavy lifting, by utilizing the Constellation orchestration layer.

    the client device plays active and vital role, acting as the layer -This includes transforming JSON metadata into HTML code

    server load is minimized, creating an even faster and more responsive user experience

    Infinity server and DX API

    In the Constellation architecture, the Pega Infinity Server acted as a brain holding the business rules, logic, and data, while the orchestration and presentation were handled by the user's device.

    Communication between both sides is covered by the use of DX API [case data + UI metadata]

    Constellation UI services

     UI-related tasks are separated into two separate services
    App-static - a client application-specific UI static content delivery service
    UI assets (images, custom components, localizations) authored by clients are application-specific
    cloud-based multitenant service or as a deployable service known as the App-Static service
    must be safely stored and protected

    requires authentication for all APIs (for both read and write). Reading or writing of customer-generated content is covered by the signed token

    PEGA CDNConstellation Pega UI static content
    JavaScripts generated by Pega and that are part of Pega Platform
    The same service for all clients
    can be made publicly available for quick access
    read-only and does not require authorization

    Messaging Service

    the Messaging Service, which realizes a server-to-client push architectural component of Constellation

    components-to-topics subscriptions made through the WebSocket connection

    Infinity publishes data --> Message Broker through an HTTP REST connection.
    The Message Broker then pushes --> browsers that registered

    for example, charts that update in real-time, or a bell icon with a badge

    Greater than the sum of its parts

    The orchestration layer, the Infinity server, and the robust Messaging Service collectively deliver a faster, more responsive, and highly scalable user experience

    Constellation hands-on L3

     Learings from Characteristics of Constellation Architecture

    The Constellation UI employs a Center-out™ approach. It is API-first, built on a model-view-controller (MVC) architectural framework and interacts with users through a prescribed UI in a stateless manner.

     Model-view-controller (MVC)




    • The model is responsible for modeling data and business logic.
    • The view manages the presentation layer and user interactions.
    • The controller is the connection between the model and the view, and handles user inputs which it translates into appropriate actions in the model.

    model - Pega Platform and its data, business logic, and workflow
    view - Constellation design system front-end User Experience
    controller -architecture orchestration layer is the Controller which conencts model to channel using API - Digital Experience (DX) API.


    Microservices

    Designing software applications as a collection of small, self-contained, and autonomous services

     The design of each service is small and responsible for a single specific end-to-end business function . They operate independently of each other and through well-defined interfaces

    limits the impact of changes in one service on the overall system.
    each service can be scaled individually based on demand

    Stateless architecture

    Each interaction (request) between client and server occurs as a separate transaction
    Server does not maintain any state information about the previous interactions

    Constellation architecture shifts towards stateless architecture, which results in ending requestor sessions and releasing the Pega Clipboard after each DX API call.

    Client orchestration
    generation of the UI and orchestration of UI components from the server to the client side

    All the modules responsible for generating UI and orchestrating actions are in client and communicates with the server only to exchange information

    User interface rendering are carried out fully on the client device by the Constellation design system

    Prescribed UI

    Ensures consistency across different parts of an application, or multiple applications within the same ecosystem.

    all of the elements are built from the same library of prescribed components

    Modular architecture

    Designing software around smaller, reusable modules - each module houses a specific functionality and provides an interface to interact with it

    Pega Infinity fully supports a modern, modular approach to application building, which enables the grouping of collections of Rules that address specific purposes into reusable modules.

    Center-out

    focuses on delivering customer and business outcomes by defining Microjourneys® to reach those outcomes

    API-first

    Designing applications prioritizes designing and building an API before working on any other aspects of the application (such as user interface or backend components).

    Pega Constellation applies DX APIs to provide a standardized way of interacting with Pega Platform through a set of model-driven APIs.