help desk
Whenever you have tables that will need to be accessed to, you can create a Model Package automatically by checking it's sed_dev_table.generate_model_package field and hit [generate].
The Model package will automatically be placed inside <module>/package/model/ folder
It will contain all the basic functionalities to access/create/edit your table entries.
You should always attempt to first use this Model package because it will create a basic framework to work from.
Sometimes, the Model package will not contains every features that you will need during your development. That is when you will need to "supercharge" the Model package.
Stuff that you may need that is not part of the Model package includes:
To supercharge a Model package, create a new package (or use an existing one) and %include_once the Model package at the top of the page. You will supercharge a Model package when your current package have the exact same name.
From this file, you can add those specific features that you need to facilitate your task.
You can then, include that file in your page/resource instead of the Model package directly.
Ex: supercharge a create function
I had to create a custom validation on the create of fee_schedule_version. In my supercharge package, I did this:
{_{ %include_once "/site/ps_core/package/model/p_ps_fee_schedule_version.sn"; }}\{_{ package ps_fee_schedule_version function create(fields) //!code Supercharge Model package to add a validation to avoid date overlap // Make sure end_date is after start_date res = ps_fee_schedule_version::validate_date_fields(fields); if res.type() eq "sed_error::Error" then return res; endif // Look for date overlap res = ps_fee_schedule_version::find_date_overlap(fields); if res.type() eq "sed_error::Error" then return res; endif if res then // Overlap found return sed_error::new_error(ps_fee_schedule_version::ERROR_USER_DATE_OVERLAP, current_function() .+ " - Error: Date overlap", fields); endif return super(1).ps_fee_schedule_version::create(fields); // super(1) gives me access to the Model package original function. endf [...] endp }}
Répondu le : 2022-08-26 07:00:00