Page 1 of 1

Fetch inventory category custom value

PostPosted: Tue Sep 29, 2020 10:34 am
by pricerc
What's the quick-and-easy way to get the custom field value for an inventory category?

I'm in an SO_Line "Property Changed" event, and I want to do a calculation based on an "ExpiryDays" integer value attached to IN_Category1.

I have a SalesOrderLine object, and can get my inventory object.

At this point, I'm having a senior moment. Or it could be that I need lunch.

Either way, I'm stuck on then getting the category custom field value.

Help !?

Re: Fetch inventory category custom value  Topic is solved

PostPosted: Tue Sep 29, 2020 12:27 pm
by Mike.Sheen
There is a static (shared in VB) method of the JiwaFinancials.Jiwa.JiwaApplication.CustomFields.CustomFieldValueCollection class called ReadCustomFieldValue.

You can use that to get the contents of any custom field.

It's overloaded, so there are three signatures:

Code: Select all
Public Shared Function ReadCustomFieldValue(Manager As JiwaApplication.Manager, ValuesTableName As String, ValuesFKIDColumnName As String, ValuesSettingIDColumnName As String, IDColumnName As String, TableName As String, ID As String, SettingName As String) As String

And
Code: Select all
Public Shared Function ReadCustomFieldValue(Manager As JiwaApplication.Manager, CustomFieldModuleName As String, ID As String, SettingName As String) As String

And
Code: Select all
Public Shared Function ReadCustomFieldValue(Manager As JiwaApplication.Manager, ValuesTableName As String, KeyField As String, ID As String, SettingName As String) As String


Here's an example pulled from a working plugin to read a debtor custom field value:

Code: Select all
string caseRatePart = JiwaFinancials.Jiwa.JiwaApplication.CustomFields.CustomFieldValueCollection.ReadCustomFieldValue(salesOrder.Manager, "Debtor Maintenance", salesOrder.Debtor.DebtorID, "CaseRatePart");


It's using the signature of the 2nd method to get a debtor custom field value (the one I prefer to use). The 2nd parameter is the CustomFieldModule name, which comes from the SY_PluginCustomSettingModules table - in your case that would be "Inventory Category 1". The 3rd parameter is the debtor ID - you want that to be the ID of the IN_Category1 associated with the sales order line item. The 4th param is the custom field name.

Re: Fetch inventory category custom value

PostPosted: Tue Sep 29, 2020 1:18 pm
by pricerc
Thanks Mike, that'll go nicely into a helper function.