Custom Field Default values  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Custom Field Default values

Postby SBarnes » Tue Dec 03, 2019 3:48 pm

Is there a simple way to provide default values for custom fields on a debtor or product?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1617
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Custom Field Default values  Topic is solved

Postby Mike.Sheen » Tue Dec 03, 2019 5:23 pm

SBarnes wrote:Is there a simple way to provide default values for custom fields on a debtor or product?


Using the SetValue method of the Valuecollection inside a handler for CreateEnd or CopyEnd is the only way right now...

So in the case of an Inventory item:

Code: Select all
Inventory.CustomFieldValues.SetValue<string>("My string custom Field", "My Plugin Name", "this is the new value");
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: Custom Field Default values

Postby SBarnes » Tue Dec 03, 2019 5:27 pm

A nice to have and I realise this might create a fair bit of work, would be if you could define it in the plugin editor when the field is added as I was hoping to avoid code. I can add a service request if that will help?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1617
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Custom Field Default values

Postby Mike.Sheen » Tue Dec 03, 2019 5:51 pm

SBarnes wrote:A nice to have and I realise this might create a fair bit of work, would be if you could define it in the plugin editor when the field is added as I was hoping to avoid code. I can add a service request if that will help?


By all means!

I had intended to have our standard maintenance business logic pattern to have a create from template function which may overlap this default custom field improvement you're asking for here.

To give an example as to how this would work, Inventory Maintenance would have a checkbox on it somewhere indicating the item is a template item. Template items are excluded from everything (you can't sell them, select them in searches, reports, the works) except for when creating a new item from a template item. The ribbon would have a new button "New from Template" which is a drop-down list showing you all the items which are marked as template items - this would essentially just load the template item, then copy it - including custom field values.

And that is a nice segue into highlighting an existing backlogged improvement relating to custom fields and copying - Add checkbox "Copy" for custom fields.

Hopefully I can make all 3 improvements play nice together.
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: Custom Field Default values

Postby SBarnes » Tue Dec 03, 2019 6:14 pm

While what you are describing would work for strings and numbers my only question on the templates is how do you handle something like a custom date fields or dates full stop where you want to default them?

I do like you template idea though, I have seen customers do this with copying a product that never gets used, templates which you could even carry a little bit further where you could possibly define rules or conditions like when classification is XYZ use template ABC, which could definitely enforce default values for products or debtors that some customers want to do, this might however make it more complex than you were intending.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1617
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Custom Field Default values

Postby SBarnes » Wed Dec 04, 2019 6:59 am

Hi Mike,

Having given this one some thought and whilst your idea is definitely I believe worth doing perhaps another way of going for what I was describing would be to extend the CustomFieldPlugin plugin to support an On New event and On Saving event that way although it doesn't avoid having to have code you would be able to use the first to set default values easily and the second to validate values for custom fields through out the system.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1617
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 3 guests

cron