Logic Inheritance
In Pricefx, there is a feature called logic inheritance which allows you to:
create/modify elements of the accelerator logic to suit your use case;
butkeep the accelerator’s out-of-the-box logic unchanged, so you can easily upgrade to future versions.
See also documentation about Parent Logic.
As of July 2023, Pricefx Studio support of logic inheritance is on the way, so in this article, we refer to Pricefx user interface for building logics (https://pricefx.atlassian.net/browse/PFAUT-717).
In this section:
Add Custom Field to Price List/Grid
Navigate to Administration › Logics › Generic Logics.
Add a new generic logic:
Name – Select Training_ParentPriceListLogic.
Parent Logic – Select ParentPriceListLogic.
Note: This dropdown field contains all the existing calculation logics available within the system and by selecting one, the system will transfer all the fields and logic calculations to your new logic.Valid After – Set it based on guidelines in your project, or now, for test purposes, simply use January 1st of the actual year.
Status – Set it to Active.
Review the logic content.
When you edit your new logic, you will see all the elements inherited from the parent logic.
When looking at the code of some inherited element, you will see a message that this element is inherited, i.e. its code comes from the original parent logic and we can eventually overwrite that code within this new logic.
Add a new element. It will be added at the end of the list of elements.
Type – Select Groovy (Function).
Name – TrainingCustomField
Display Mode – Everywhere
Caution: Remember to uncheck the option Never.Format Type – Money
Enter this code:
12.3
Note that the code editor of this element does not have the inheritance indicator because its code is defined within this logic.
Save the logic.
Test the calculation.
Recalculate your Live Price Grid.
Review the value in column TrainingCustomField.
See Tips on Logic Customization for more details on configuring a test LPG.
Modify/Override Behavior of Existing Field
When you open your inherited logic Training_ParentPriceListLogic, there is an element named Cost which has the code/behavior inherited from the logic ParentPriceListLogic.
You can override the out-of-the-box behavior of the accelerator and calculate Cost in a different way. But the out-of-the-box accelerator logic will stay unchanged because the change will only be in your inherited logic.
Find and edit your generic logic Training_ParentPriceListLogic.
Select the element Cost.
In the Editor, use the Override action.
Note: This will copy the element’s content from the parent logic to your logic. You can modify it and perform any operation and lookup you need to gather the cost in the way you need.Comment out the original code.
At the very beginning of the element code, insert your own implementation:
return 100.0
Save the logic.
Test the calculation.
Recalculate your Live Price Grid.
Review the value in column Cost.