Changed Custom Fields on Debtor and Inventory Save  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Changed Custom Fields on Debtor and Inventory Save

Postby SBarnes » Fri Feb 19, 2021 11:47 am

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.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1617
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

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

Postby Scott.Pearce » Mon Feb 22, 2021 9:01 am

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 32 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.
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: Changed Custom Fields on Debtor and Inventory Save

Postby SBarnes » Mon Feb 22, 2021 10:33 am

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?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1617
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Changed Custom Fields on Debtor and Inventory Save

Postby Mike.Sheen » Mon Feb 22, 2021 12:59 pm

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.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2440
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 755

Re: Changed Custom Fields on Debtor and Inventory Save

Postby SBarnes » Mon Feb 22, 2021 1:06 pm

And I didn't get the hose don't tell Ryan :lol:
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1617
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Changed Custom Fields on Debtor and Inventory Save

Postby Mike.Sheen » Mon Feb 22, 2021 1:11 pm

SBarnes wrote:And I didn't get the hose don't tell Ryan :lol:


lol
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2440
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 755

Re: Changed Custom Fields on Debtor and Inventory Save

Postby Scott.Pearce » Mon Feb 22, 2021 3:07 pm

SBarnes wrote:And I didn't get the hose don't tell Ryan :lol:

haha
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 3 guests

cron