Page 1 of 2

Custom Field Sizes

PostPosted: Wed Jul 28, 2021 3:14 pm
by SBarnes
Is it possible to increase the size of a custom field above the current 255 character limit by simply altering the table such as for inventory?

Re: Custom Field Sizes  Topic is solved

PostPosted: Wed Aug 11, 2021 6:49 pm
by Mike.Sheen
SBarnes wrote:Is it possible to increase the size of a custom field above the current 255 character limit by simply altering the table such as for inventory?


The underlying table columns for all our custom field values has the contents to VARCHAR(MAX) which has a 2GB limit on size.

The grid cell type, however, has a default value for the MaxLength property - which is 255 characters.

You can set the MaxLength in the FormatCell method of the CustomFieldPlugin of the plugin which the custom field is defined:

Code: Select all
public void FormatCell(JiwaFinancials.Jiwa.JiwaApplication.IJiwaBusinessLogic BusinessLogicHost, JiwaFinancials.Jiwa.JiwaApplication.Controls.JiwaGrid GridObject, JiwaFinancials.Jiwa.JiwaApplication.IJiwaForm FormObject, int Col, int Row, JiwaFinancials.Jiwa.JiwaApplication.IJiwaCustomFieldValues HostObject, JiwaFinancials.Jiwa.JiwaApplication.CustomFields.CustomField CustomField, JiwaFinancials.Jiwa.JiwaApplication.CustomFields.CustomFieldValue CustomFieldValue)
{            
   if (GridObject.ActiveSheet.Cells[Row, Col].CellType is FarPoint.Win.Spread.CellType.TextCellType)
   {
      FarPoint.Win.Spread.CellType.TextCellType cellType = (FarPoint.Win.Spread.CellType.TextCellType)GridObject.ActiveSheet.Cells[Row, Col].CellType;
      cellType.MaxLength = 2000;
   }
}


This above will change the Contents MaxLength to 2000 characters for all custom fields defined in the plugin.

Re: Custom Field Sizes

PostPosted: Wed Aug 11, 2021 7:06 pm
by SBarnes
And now I am confused we had a client get a truncation error from SQL in the inventory import screen, I've seen the screenshot they sent me and they told me they were importing custom fields.

I think I am going to need to get the input spreadsheet from them and se what I can figure out.

Thanks for the code to increase what the grid will take.

Re: Custom Field Sizes

PostPosted: Thu Aug 12, 2021 3:20 pm
by SBarnes
Ok mystery solved so after I got the import data from the customer the problem was actually the details field(Aux3), the only problem with the error about truncation they go it they couldn't tell which field was causing it.

Re: Custom Field Sizes

PostPosted: Thu Aug 12, 2021 5:43 pm
by Mike.Sheen
SBarnes wrote:Ok mystery solved so after I got the import data from the customer the problem was actually the details field(Aux3), the only problem with the error about truncation they go it they couldn't tell which field was causing it.


Ah.

We make our support dept. verify the claims a customer makes before handing it off to us for this very reason.

Re: Custom Field Sizes

PostPosted: Thu Aug 12, 2021 5:52 pm
by SBarnes
Support department what's that? :lol:

Last time I checked I thought I had a sign around my neck that said everybody with a strange and stupid problem please drop it at my feet with no details and I'll solve it :shock:

Re: Custom Field Sizes

PostPosted: Thu Aug 12, 2021 6:02 pm
by pricerc
SBarnes wrote:Ok mystery solved so after I got the import data from the customer the problem was actually the details field(Aux3), the only problem with the error about truncation they go it they couldn't tell which field was causing it.


It was only a very recent version of SQL that finally started providing that information.

Microsoft have some of the laziest error messages.

Re: Custom Field Sizes

PostPosted: Thu Aug 12, 2021 6:07 pm
by SBarnes
Now now, if we are going to start bashing the big corporates can we please NOT just limit it to Microsoft. :D

Re: Custom Field Sizes

PostPosted: Mon Sep 13, 2021 10:56 am
by SBarnes
Can I increase the size of Aux3/ Details in inventory to max size without any major issues, and if I can what might need to be done in a plugin to set the length on the control itself.

Re: Custom Field Sizes

PostPosted: Mon Sep 13, 2021 6:03 pm
by Mike.Sheen
SBarnes wrote:Can I increase the size of Aux3/ Details in inventory to max size without any major issues, and if I can what might need to be done in a plugin to set the length on the control itself.


You just need to set the MaxLength of the DetailsTextBox on the form. The business logic doesn't trim anything on read or write, and neither does the form.

Code: Select all
InventoryForm.DetailsTextBox.MaxLength = 250;


Keep in mind if you change it to VARCHAR(MAX) you won't be able to index on that field - which may or may not be important to you, depending on how that field is going to be used. We currently don't have an index on it, but if you plan on doing any queries to find items by the contents that field, then perhaps consider VARCHAR(8000) or something.