Page 1 of 1

Changed Custom Fields on Debtor and Inventory Save

PostPosted: Fri Feb 19, 2021 11:47 am
by SBarnes
How can you quickly get a list of changed custom fields on a debtor and inventory item at the save start so you can prevent the save if certain custom fields have been changed by the user?

This is situation where you can still edit certain custom fields but now others from their initial values.

Re: Changed Custom Fields on Debtor and Inventory Save  Topic is solved

PostPosted: Mon Feb 22, 2021 9:01 am
by Scott.Pearce
Iterate through Inventory.CustomFieldValues and look at the .ChangeFlag of each item. I've attached a plugin that does this:

Plugin List Changed Inventory Custom Fields.xml
(33.84 KiB) Downloaded 34 times


You might get false-positives when you *copy* an inventory item though (i.e. custom fields will show as user-changed but they were not - they were just copied in from the source).

I would think a better way of dealing with your problem would be to *lock* certain custom field cells when creating a new inventory item, then unlocking them again afterwards.

Re: Changed Custom Fields on Debtor and Inventory Save

PostPosted: Mon Feb 22, 2021 10:33 am
by SBarnes
Thanks Scott,

I had spent some time on this where I ended up on a static class having a list of field names called required and one called no change and then wrote code to check the fields in the save before like your example.

After doing this I then introduced a way of having regular expressions against the custom fields as well for validation, works quite well.

A suggestion might be for Jiwa to have the following on custom fields but I don't know how much work this would create.

1. Required Flag
2. Regular Expression for validation
3. Human readable error message if 1 or 2 didn't pass to throw as the exception message.

I am happy to lodge it as a suggested enhancement if you think its got legs?

Re: Changed Custom Fields on Debtor and Inventory Save

PostPosted: Mon Feb 22, 2021 12:59 pm
by Mike.Sheen
SBarnes wrote:I am happy to lodge it as a suggested enhancement if you think its got legs?


I've tacked it onto DEV-6705 for ya.

Re: Changed Custom Fields on Debtor and Inventory Save

PostPosted: Mon Feb 22, 2021 1:06 pm
by SBarnes
And I didn't get the hose don't tell Ryan :lol:

Re: Changed Custom Fields on Debtor and Inventory Save

PostPosted: Mon Feb 22, 2021 1:11 pm
by Mike.Sheen
SBarnes wrote:And I didn't get the hose don't tell Ryan :lol:


lol

Re: Changed Custom Fields on Debtor and Inventory Save

PostPosted: Mon Feb 22, 2021 3:07 pm
by Scott.Pearce
SBarnes wrote:And I didn't get the hose don't tell Ryan :lol:

haha