Event Mapping PeopleTools 8.59

8.59 Event Mapping Override

I’m a big fan of Event Mapping, I wasn’t always, but I am now. I’ll maybe tell you the story about that another time. I know some people are not really interested in what it has to offer and I think that is because people are not really looking at what can be done with it. I’ve got loads of cool stuff that I’ll get together into a presentation at some point and prove Event Mapping is the place to be.

Anyway, back on topic. Today I want to look at the 8.59 Event Mapping changes and in particular one of the big deals for me, the Event Override. Up until now you could only use Event Mapping to add on to delivered code, which is fine if you want to change a value, but not if you want to stop something from happening.

Say you have a component that adds people to a team and the delivered SavePostChange has code that when you successfully add a new member to the team it sends out an email to that person. Now you want to change this so that if the person added has a mobile number then rather than an email it sends a text. With the old Event Mapping you could only add code before or after, so the email would still get sent and after the event then you could send a text. That would be no good so you would have to directly customise the delivered code to stop the email and send the text. The situation changes with the birth of the Event map override, we can stop the delivered code running and put a copy of that code into the Event, add in our logic to make it select from email or text and we are good to go. This is a big deal as we have fundamentally changed the way a delivered component works without having to intrusively customise the code.

My Test Page

I know people will point out the maintenance issues, what happens when the delivered code is updated and my event map no longer has the correct code. This is a challenge that we have with any customisation, and make no mistake this is still a customisation, it just allows your ‘Stay Current’ upgrades to run a lot smoother. Also, I am sure Oracle could come up with a nice way to flag event map code that is linked to an object that changes in an upgrade. There’s something for you to work on Oracle, please (if you haven’t done it already!)!

The Post Build ‘Delivered’ Peoplecode

On to my little demonstration. I created a simple page with two fields on it, a textbox to display a string and a ‘Total’ field to display a number. I had the ‘Total’ field set to 6 at the start. Then I added Component Post Build code which will set the Text box to read ‘The colour is Red’ and it will add 4 to the value of ‘Total’ (which should be 6, giving 10).

The Event Map Code

Then I created my Application package by implementing PT_RCF:ServiceInterface, just like you would normally. In this code I want to set the Text box to read ‘The colour is Blue. We have overridden the POST BUILD’. Now this result could be achieved with a Post Event Map as all it has to do is after Post Build sets the text box just overwrite the value. This is why I introduced ‘Total’, which starts with a value of 6, but if Post Build fires will add 4 to become 10 and in my Event map code I add 10 to the ‘Total’. Because we are overriding the Post Build the result should be 6 + 10 = 16 and not 6 + 4 + 10 =20, this is because the 4 should not be added as the Post Build code will not run.

So that is my little test component and code done. An IMPORTANT new step to carry out is once you create a new component is, you need to ensure the entries are updated into the Elastic Search definition PTPORTALREGISTRY which is used when using the new Homepage search. So ensure you run an incremental build of that definition. otherwise you will not find your CREF later when configuring the Event Mapping.

So we have our App Designer project, what do we do next. Well, I always follow my Event Mapping mantra which is: ‘It’s as easy as 1,2,3’.

  1. Create an Application Package for your code.
  2. Create a Related Content Service.
  3. Map the Event.

Let’s create the Related Content Service. In 8.59 this is a little different to what we are used to. They have finally moved the Event Mapping piece away from that terribly confused Manage Related Content Service component. You can still create your related content service by going to Home > PeopleTools > Portal > Related Content Services > Define Related Content Services. Or you can go to Home > PeopleTools > Portal > Event Mapping > Event Mapping Configuration, we will look at this page as it is new to 8.59.

The New Event Mapping Service Creation

There are two tabs on the left, pick Event Mapping Services and you will be presented with a long list of the already created Service IDs. But we want to create a new one for our project so click on one of the + buttons on the right to add a row. Give your service an ID and name, then map the Application Class to it and PeopleSoft does the rest for you. You can go into the old Define Related Content Services page if you want to see your created service.

The New Event Mapping Configuration

Finally, we go to the Configure Event Mapping tab on the left and this show a list of the Event Maps. We want to create a new one click the ‘Add Configuration’ button. Note if it does not appear, you probably have not run the Elastic Search definition PTPORTALREGISTRY.

Setting The Event Map

So find your CREF and then choose the Event Level you are mapping to, in this case Component Post Build. Then add the Service ID that you just created and we want Override for the Sequence. Save and it is ready!

Navigation Helper

One last thing, when on the Configure Event Mapping page on the grid where your Content Reference is hit the little ‘Navigation’ chevron on the right and it pops up a box with the navigation.

The Result Of The ‘Delivered’ Component Post Build Code Running

We navigate to the component without the event map override in place and this is the result.

The Result When The Event Map Override Is Enabled

Now with the Event Map Override in place and the result we get is Red and 16. Result it works…

Welcome to a whole new world of less intrusive coding! And if you are not impressed with that, I’ve got some cool ideas that you can try with Event Mapping coming in the future.

Thanks for reading…