How to Implement Copy or CreateWithReference functionality for PDI Objects
Sometimes we require ‘Copy’ or ‘Create with Reference’ for partner developments to ease the business process, I would like to share some sample implementation in this blog.
Business Object Definition :
A reference ID is defined in the business object to refer the copied instance during runtime. And an action copy is defined to copy the desired values, alternatively, you can write the same script on event after-modify and trigger it with the help of round-trip functionality available in datamodel properties to load while opening the QA. I prefer to script in copy action which I feel looks clear and improves performance.
Action-Copy Script :
Let’s Start with the configuration of QA screen. There is a reason to start the configuration from the QA screen, which is explained in upcoming steps. For now, create an Event Handler and add the below operation sequentially,
To create a new instance from UI, similar to the ‘New’ button configuration
The data operation is necessary to assign the captured Reference ID to the BO Data Field so that it can be utilized by the Action Copy Script file.
Bind Copy Action :
This will trigger the BO Action-Copy and fill up the values
Let’s create an OBN Inport and assign the above Handler on its onFire
OBN Inport: Its the key part to perform the copy operation, it recieves the key using OBN and performs the above-mentioned operation
Now QA is ready to handle the outported reference ID from OWL.
Let’s move on to the OWL screen,
In the OWL Screen, add a Copy Button, then create a Handler to handle the OBN Navigation to the QA Screen, As you can see the ‘Copy’ operation is now available in the dropdown of select operation and it will be available only if it should have configured in the QA screen first place (remember the reason I mentioned earlier ;))
Outport: The outport fires the Alternative Key([AlternativeKey] element ID : ID;) to the QA screen with the help of OBN
Now configure the handler to the Copy Button as shown in the below image and test.
How it works:
When the Copy Button is clicked, The alternative Key is passed to the QA screen through OBN, then in QA it is captured and assigned it to the Reference ID, on the OnFire Handler of Inport, the Copy action is triggered which retrieves the values to be copied with the help of Reference ID and filled it up in the current instance.
That’s all about the blog.