Service File Processing – tutorial
This article is all about working out a tutorial on service file rules in Pega.
It is a mandatory pre-requisite to go through my previous article on Service file configurations before continuing here.
I have already explained the business requirements in my previous article.
Business Requirement: External system sends us the input file with a list of customer details. For each record in the file, you need to create a new Sales case with the details provided.
Below is the input file we get from the external system.
Let’s straight away start the tutorial
Step 1: Create a new service file rule.
I have already created it in my previous post. I am going to use it
Step 2: Configure the service file rule
Service tab
Since I am going to create the sales case from the details provided in the file, my primary page will be OMXG07-FirstApp-Work-Sales
Method tab
Same configuration as we saw in the previous post.
Processing method – by record type
Record terminator – rn
Offset – 0
Length – 2
Data mode – text only
Character encoding – Default
Request tab
Same configuration as we saw in the previous article.
For the record type 10 & 99, use Skip as Map to
Map to key – MapCustomerData.Customer is the namespace for the parse delimited we created before
Below is the configuration for parse delimited rule.
I need to specify the activity in the Parse segments row. For this, I am going to create a new processing activity
Step 3: Create a new Service activity rule for processing the data
I am creating the activity in the primary page class
A simple activity with one step.
I am using the OOTB activity svcAddWorkObject, which accepts the pyStartCase, the starter flow for the sales case as the parameter. This activity can create a new case
Why svcAddWorkObject?
There are many OOTB activities to create cases in pega. Mostly all the case creation activities use the two main reusable activities createWorkPage and addWork.
The speciality of this activity is that it passes the current step page as MergePage parameter to Call createWorkPage activity.
It means the primary page in the service file rule – MyServicePage will be the current step page and it will be passed in as mergepage parameter. Remember, after parsing MyServicePage will hold the values of customername, age and sex.
Finally, in the createWorkPage activity, the MergePage content will get merged with the pyWorkPage. This is how the data from the file is passed to the case.
Note: This is not the only way to pass the data to pyWorkpage
Save the activity rule.
Step 4: Specify the activity rule in the parse segments array
Save the rule
Step 5: Prepare and run the service file rule.
Prepare a CSV file with the right test data.
Run the service file rule manually using the actions button and supply the file.
If you need, you can trace the service-file rule.
Click execute.
You should get a success message.
Step 6: Verify the run
You can always verify the case details from the designer studio.
App Explorer -> Click on the class to view the instances.
You can see 3 sales got created in the same minute!!
By the way, my current time is not 4.01 PM. It is +6 hours ahead.
One more verification: let’s see if the customer details are rightly populated in the case.
Click and open the case S-38, the last created case.
Customer name is Sandosh and age is 26. Cool.
Parse rules – map the data from external system to pega;
service-file rule – process the data.
Finally the missing piece file listener – listen the file and invoke processing via service file.
We will see about file listener in the next article