Introduction
This tutorial guides you through creating an activity that automatically updates task priorities to ‘High’ when their due dates are within two days of the current date.
Prerequisites
- A Data Type called ‘Tasks’ containing task records for your team
Step-by-Step Guide
- Create or Open an Activity
First, create a new activity or open an existing one in Dev Studio where you want to implement this functionality.
For this example, we’ll create an activity called ‘UpdateTaskPriority’.
- Configure Pages and Classes
Set up the pages and classes with:
- The list of tasks
- The instance that will be used to open the object
- Configure Activity Steps
Follow these steps to implement the update logic:
Step 1: Load the Task List
- Use the method ‘Obj-Browse’ to load the list
- In the configurations:
- Set PageName to ‘TaskList’
- Set ObjClass to ‘HTP-HowToPega-Data-Tasks’
- In the fields configuration:
- Set your identifier property (in this case .pyGUID)
- Mark the ‘Select’ checkbox
Step 2: Configure the Loop
- Set the loop option to ‘For each embedded page’
Step 2.1: Open Each Object
- Use the method ‘Obj-Open’ to load the object
- Set the ‘Task’ page to the ‘Step Page’
- Mark ‘Lock’ and ‘ReleaseOnCommit’ checkboxes (these can be adjusted based on your design requirements)
- For PropertyName, use the identifier property (in this case ‘pyGUID’)
- For PropertyValue, set ‘TaskList.pxResults().pyGUID’
- Configure the ‘Jump’ option to handle the loop flow
Step 2.2: Check Due Date and Update Priority
- Set the when condition to check if the DueDate is less than or equal to 2 days from today:
- @DateTimeDifference(@CurrentDateTime(),.DueDate,“D”)<=2
- Use the method ‘Property-Set’
- Set the ‘Task’ page to the ‘Step Page’
- Set the ‘.Priority’ to “High”
Step 2.3: Save the Updated Task
- Use the method ‘Obj-Save’
- Set the ‘Task’ page to the ‘Step Page’
- Select the ‘WriteNow’ checkbox
Step 2.4: Remove the Page
- Use the method ‘Page-Remove’
- Set the ‘Task’ page to the ‘Step Page’
Step 3: Exit the Activity
- Set step label to ‘EXIT’ (referenced in the jump configuration)
- Use the method ‘Exit-Activity’
Now just run the Activity and check for the results.
References
https://academy.pega.com/topic/activity-methods-reference/v1











