Running arbitrary PeopleCode statements and scripts in the PIA has always been a desirable feature for me. I previously scratched this itch by writing a proof of concept utility that allows you to Compile and Run PeopleCode Online. While the utility is helpful, it is completely decoupled from the Online PeopleCode Editor that I play in. I decided to incorporate the Run PeopleCode functionality into the Online PeopleCode Editor project. You can check out the GitHub repository to download the latest version of the Online PeopleCode Editor project that contains this functionality.
To use the Run PeopleCode functionality in the Online PeopleCode Editor you must create an App Class that will contain the code to be run. Unfortunately the current version of the Online PeopleCode Editor does not allow for new object creation, so you will need to use App Designer to create the new App Class.
The Class will need to implement
PSM_RUN_PC:IRunner Interface and have a Run method that returns a String. Here is an example:
import PSM_RUN_PC:IRunner; class Test implements PSM_RUN_PC:IRunner method Run() Returns string; end-class; method Run /+ Returns String +/ /+ Extends/implements PSM_RUN_PC:IRunner.Run +/ /* Write PeopleCode to be ran here */ Local string &sOutput; &sOutput = "PeopleTools Version: " | %ToolsRelease; Return &sOutput; end-method;
After the App Class is created you can use the Online PeopleCode Editor to open and edit the App Class PeopleCode. The editor will
present a “Run” button if it detects an App Class that implements
Clicking the Run button will invoke the Run method of the App Class and it will display the returned String in a modal window. Here is the output of the Run method of the App Class PeopleCode above:
This example simply runs a PeopleCode statement to get the PeopleTools version for the environment; however the PeopleCode programs contained in the Run method can be as complex as the developer desires them to be.