Page 1 of 1

Updating a custom fields value on inventory

PostPosted: Thu Mar 04, 2021 11:14 am
by SBarnes
I need to update a custom field value on the inventory item to the database without updating the inventory item i.e. I don't want the last saved date and time to update, will the following work where jinv is the business object?

Code: Select all
 jinv.CustomFieldValues.get_ItemFromSettingName("FieldName").Save(jinv.InventoryID);

Re: Updating a custom fields value on inventory  Topic is solved

PostPosted: Thu Mar 04, 2021 4:47 pm
by Mike.Sheen
SBarnes wrote:I need to update a custom field value on the inventory item to the database without updating the inventory item i.e. I don't want the last saved date and time to update, will the following work where jinv is the business object?

Code: Select all
 jinv.CustomFieldValues.get_ItemFromSettingName("FieldName").Save(jinv.InventoryID);


It might - it's not something I'd recommend, though - and it'll cause the custom setting value's LastSavedDateTime to be updated - and although I suspect you just care about the IN_Main.LastSavedDateTime not changing - it would mean any subsequent save of the same custom field value will fail, as the LastSavedDateTime of the custom field will have changed between read and save.

You could just do a direct SQL Inert / Update on the table.

Re: Updating a custom fields value on inventory

PostPosted: Thu Mar 04, 2021 5:35 pm
by SBarnes
Thanks, I hadn't considered that it may be easier to pass the business object into the routines and do one final save at the end.