Possible Bug in Inventory Import  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Possible Bug in Inventory Import

Postby SBarnes » Fri Mar 05, 2021 2:06 pm

I believe given we have a customer who has an issue created by this, that there is no validation of custom fields in the inventory import, by this I mean we have ended up with text in a numeric field.

This then has caused a custom view that casts what it expects to be a number to a numeric to fall over.

On a quick look through the code from the import screen it would appear when you delve into the object that the sets custom field is as follows and then the custom field value never checks back to the custom field's type

Am I correct in my understanding of this as I'll log it as a bug through the service desk if it is?

Code: Select all
private void SetCustomField(ref Inventory Inventory, string Value, string RowData, string[] Row, int RowNo, Mapping Mapping)
{
    CustomFieldValue value2 = Inventory.CustomFieldValues.get_ItemFromSettingName(Mapping.DestinationProperty.RecID);
    if (value2 > null)
    {
        value2.Contents = Value;
    }
}

Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1617
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Possible Bug in Inventory Import  Topic is solved

Postby Mike.Sheen » Sat Mar 06, 2021 12:37 pm

SBarnes wrote:Am I correct in my understanding of this as I'll log it as a bug through the service desk if it is?


Yes, technically it is a bug, but it's not isolated to the inventory import.

At the business logic level (that is, outside of the grids we provide for user interaction with custom field values), we don't perform any validation or conversion at all, except for recently with dates (in which case if not blank or null we TryParse to date and then format to .ToString("s") to enforce ISO 8601 format).

For the other CellTypes we don't validate or cast - and we should - it wouldn't take a lot of effort for us in the property setter of the Contents property to validate and cast based on the CellType in the same manner as we do with dates.

Just another thing we "never got around to". Logged as DEV-8634
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: Possible Bug in Inventory Import

Postby SBarnes » Sat Mar 06, 2021 9:15 pm

Hi Mike,

Yeah I'd realised it was bigger than just the import inventory form, if the customer wants this fixed would a plugin that did the following steps work not only for the import screen but across the board?

1. Hook onto the Business Object Factory's after setup event.
2. if the Business Logic object is JiwaFinancials.Jiwa.JiwaApplication.IJiwaCustomFieldValues interface roll over the collection and attach an Event for Notify property changed event for each item in the collection given CustomFieldValue implements this.
3. If the property that is changed is Content then cast the sender to JiwaFinancials.Jiwa.JiwaApplication.CustomFields.CustomFieldValue
4. And then pretty well follow what the current Setter on Contents does to check for DateTime but check the parsing for other data types like float and int.

If this would work and the customer agrees they want it I'll post the result back here in case it's useful to others.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1617
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Possible Bug in Inventory Import

Postby SBarnes » Thu Mar 18, 2021 8:10 am

The attached plugin should cover it, it wasn't quite how I wanted to do it but it works off the fact that a business login object implements JiwaFinancials.Jiwa.JiwaApplication.IJiwaCustomFieldValues and JiwaFinancials.Jiwa.JiwaApplication.IJiwaSaveable and then attaches a save start event to do the validation.

One other thing I thought of was it would be handy for the import screens for inventory and debtor if they exposed the business object they use as currently you can't get at them for only that specific instance i.e. only in the import screens to perform specific functionality on the import against the inventory or debtor object.
Attachments
Plugin Attkey Validate Custom Fields.xml
Validate Custom Fields
(33.25 KiB) Downloaded 22 times
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