Validate Custom Text Field

Discussions relating to plugin development, and the Jiwa API.

Validate Custom Text Field

Postby SBarnes » Fri Aug 07, 2020 10:03 am

Is there a way to add validation to a custom field on a debtor for instance if the custom field was a phone number where it was required to start with +61 or that the field contained the necessary elements to be an email address?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1621
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 176

Re: Validate Custom Text Field

Postby pricerc » Fri Aug 07, 2020 12:44 pm

SBarnes wrote:Is there a way to add validation to a custom field on a debtor for instance if the custom field was a phone number where it was required to start with +61 or that the field contained the necessary elements to be an email address?


yes.
/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
https://aerp.co.nz
User avatar
pricerc
Senpai
Senpai
 
Posts: 504
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 20

Re: Validate Custom Text Field

Postby SBarnes » Fri Aug 07, 2020 12:46 pm

Which is?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1621
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 176

Re: Validate Custom Text Field

Postby Scott.Pearce » Fri Aug 07, 2020 12:46 pm

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

Re: Validate Custom Text Field

Postby Scott.Pearce » Fri Aug 07, 2020 12:47 pm

I think Mike has an incoming post with some possibilities...
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 743
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: Validate Custom Text Field

Postby Mike.Sheen » Fri Aug 07, 2020 12:50 pm

SBarnes wrote:Is there a way to add validation to a custom field on a debtor for instance if the custom field was a phone number where it was required to start with +61 or that the field contained the necessary elements to be an email address?


You can use the ErrorText property of the grid cell to display an error indicator with a tooltip indicating the problem:

Code: Select all
grid.ActiveSheet.Cells(Row, grid.ActiveSheet.GetColumnFromTag(null, "RemitNo").Index).ErrorText = "This is my error";


You can do this within the PropertyChanged handler of the custom field values collection of the object - you'll just need to iterate the grid row by row to find the right row with the custom field name or id corresponding to the one in the event parameters.

You can then also add a client cancelled exception on the Savestart event of the business logic to cancel saving if any custom field value is not expected / valid.

You could also add edit masks to the grid cell - to force things like numeric only input - but I'm not a huge fan of that approach - I prefer to display an error indicator instead.
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: 2445
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 757

Re: Validate Custom Text Field

Postby pricerc » Fri Aug 07, 2020 12:50 pm

/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
https://aerp.co.nz
User avatar
pricerc
Senpai
Senpai
 
Posts: 504
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 20

Re: Validate Custom Text Field

Postby SBarnes » Fri Aug 07, 2020 12:55 pm

Yeah well when you turn 50 and the short term memory start to go :lol: my bad.

Thanks for the reminder and suggestions.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1621
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 176

Re: Validate Custom Text Field

Postby pricerc » Fri Aug 07, 2020 12:57 pm

after reading Douglas Adams, one appreciates the importance of asking the right question....

once or twice a month, I do a pub quiz on a Tuesday night with my brother and sister. About the only time I see them, mostly.

The number of times I've wanted to answer "Yes" to a question like "Was the Queen crowned in 1952 or 1953?".... We'd win most nights :D
/Ryan

ERP Consultant,
Advanced ERP Limited, NZ
https://aerp.co.nz
User avatar
pricerc
Senpai
Senpai
 
Posts: 504
Joined: Mon Aug 10, 2009 12:22 pm
Location: Auckland, NZ
Topics Solved: 20

Re: Validate Custom Text Field

Postby Mike.Sheen » Fri Aug 07, 2020 1:02 pm

pricerc wrote:I do a pub quiz on a Tuesday night


I thought smartphones and the internet kills quiz nights... do they hold it in a giant faraday cage?
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: 2445
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 757

Next

Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 6 guests