Posts

Get and Set a property value using JavaScript

What to do if you want to get or set the value of a property using JavaScript? Set the value of a property using JavaScript To set a value to a property use the pega.api.ui.actions.setValue function defined on the webwb/pzpega_api_ui_actions.js text file rule. pega.api.ui.actions.setValue("MyPage.MyProperty", "MyValue", false, null) The third parameter is a boolean which indicates whether the second parameter is a property reference (uses the dot notation) or it's a string constant. pega.api.ui.actions.setValue("MyPage.MyProperty", "AnotherPage.AnotherProperty", true, null) The last parameter is the event object, if you pass it to the function, the properties will be taken from the context of the event. The advantage of using this function over setting it manually with vanilla JavaScript is that the elements that are observing this property will react immediately (ex. on-client visibility). Get the value of a property using ...

Server-side validation using Edit Validate rules

Image
Let's start with a short tutorial to see how server-side validation works using Edit Validate rules. Create the MobilePhone Edit Validate rule with the following Java Source: // ************************** // // Edit Validate: MobilePhone // // ************************** // java.util.regex.Pattern regex = java.util.regex.Pattern.compile("^[0-9]{9}$", java.util.regex.Pattern.CASE_INSENSITIVE); java.util.regex.Matcher matcher = regex.matcher(theValue); if (!matcher.find()) { theProperty.addMessage("[server] The phone is invalid"); return false; } return true; Create the .Phone property and set its "Use validate" option to MobilePhone . Create the EmailAddress Edit Validate rule with the following Java Source: // *************************** // // Edit Validate: EmailAddress // // *************************** // java.util.regex.Pattern regex = java.util.regex.Pattern.compile("^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}$", java....

How does Pega perform client-side validation

Image
This is the second post in the series about client-side validation in Pega. In the previous post, we've learned about the ValidationError object. In this post we will describe the steps made by the "Submit" button when we click on it. Also, we will introduce the ValidationType objects and the Validation functions . These elements are the building blocks of client-side validation in Pega so we will need to know their role when implementing it. We will study ValidationType objects and validation functions that already exist, so we will not create custom ones, that will be the subject of the next post. Before we start... Let's create the MobilePhone Edit Validate rule with the following definition. // Edit Validate: MobilePhone if (theValue.length() != 9) { theProperty.addMessage("The entered value must be 9 digits long"); return false; } else if ( !(theValue.startsWith("8") || theValue.startsWith("9")) ) { theProperty...

Display error messages in HTML fields

Image
In this post we will learn how to display and clean up error messages in the HTML fields of a Pega form manually using JavaScript. This post is part of a bigger one in which we will create custom client-side validations, and since that post was getting too big I decided to split it into small posts (divide and conquer!) The "ValidationError" object The ValidationError object just contains an error message and a reference to the HTML element to attach the error message. We can create a ValidationError object using the validation_Error constructor which is defined in the csvalid.js text file rule. // Creates a new ValidationError object var errorObj = new validation_Error(elementHTML, "Hello World!"); Display a ValidationError object Creating a ValidationError object is not sufficient for it to be displayed in the user interface. We can display the ValidationError object manually using the display_addImageError function which is defined i...

Tutorial – How to extend the disk space of a virtual machine with Linux

Introduction If our Linux operating system in a VirtualBox virtual machine is running low on disk space we can expand it using VirtualBox's Virtual Media Manager. In this tutorial we will see how to do this. Step 1. Get the partition name Run the following command to check the partition name we want to extend. Lsblk In the following image we can see that our partition name is "/dev/sda" Step 2. Modify the size of the disk Power off the virtual machine and open the "Virtual Media Manager" (Ctrl + D). Select the disk you want to modify (double click) and enter the new disk space you want. Click "Apply". Step 3. Update the size in the Linux system Start the virtual machine, open a terminal and enter the following command (replace sdX with the partition name you've found in the step 1): sudo resize2fs /dev/sdX Step 4. Test it! You can check the new size according to your Linux distribution. Reference - https://superuser.c...