Go to main content

help desk

for saving an object that was ::get throught a Model package

Asked on 2022-12-08 06:20:00

OFFICIAL ANSWER

QUICK TIP:

for saving an object that was ::get throught a Model package, you need to make sure your fields are clean before calling ::set.

  • This will remove all sn fields that are generated like `uid` and `sn_cdate`.
  • It will also remove all the virtual fields that were created in the ::_get like `modified_by_user` or any other virtual fields created in your supercharged version of the ::_get

Here is a quick solution that may help you, exemple for table ps_patient_statistic

 

// Get the statistic
statistic = ps_patient_statistic::get(1234);

// Modify statistic ...

// Clean up statistic object before save
statistic = sed_dev::context_filter(statistic, ps_patient_statistic::fields); // Removes virtual fields
statistic = sed_dev::context_map(statistic, sed_dev::sn_fields); // Removes all sn fields
// Save statistic
statistic_rs = ps_patient_statistic::set(statistic.uid, statistic);
Answer by:
Etienne Carrier

Replied on: 2022-12-08 09:22:00