-1

Below is the code that i tried in ShipmentEntry graph extension but save button is not not enabled to save the new entry of tracking number also due to this code the entire row fields got enabled.

 protected virtual void SOShipment_RowSelected(PXCache sender, PXRowSelectedEventArgs e, PXRowSelected BaseEvent)
        {
            if (BaseEvent != null)
                BaseEvent(sender, e);

            SOShipment row = e.Row as SOShipment;

            if (row == null)
                return;


                PXUIFieldAttribute.SetEnabled<SOPackageDetailEx.trackNumber>(sender, row, true);
                Base.Document.Cache.AllowUpdate = true;
                Base.Packages.Cache.AllowUpdate = true;
}

 protected virtual void SOPackageDetailEx_RowSelected(PXCache sender, PXRowSelectedEventArgs e, PXRowSelected BaseEvent)
        {
            if (BaseEvent != null)
                BaseEvent(sender, e);
            SOPackageDetail row = e.Row as SOPackageDetail;
            if (row == null) return;
                PXUIFieldAttribute.SetEnabled<SOPackageDetailEx.trackNumber>(sender, row, true);
        }

Thanks in advance for your help.

BhavyaSri
  • 150
  • 10
  • Save button is enabled only when data changes or if you set IsDirty=True on cache or use cache SetStatus method with Updated/Modified value. It looks like you want to enable only one field when the whole document is disabled because of the document status. It does go against best practice so you'll need to work harder to make that happen. Try AllowUpdate first then SetEnabled(row, false) to disable all fields and then re-enable the only one you need to be enabled. – Hugues Beauséjour Jan 23 '20 at 16:31

1 Answers1

0

The code below edits and saves the tracking number field's value to the database even when the shipment is invoiced:

sOPackageDetailEx.TrackNumber = "Some Value";
Base.Packages.Update(sOPackageDetailEx);
Base.Caches[typeof(SOPackageDetailEx)].PersistUpdated(sOPackageDetailEx);

This code must be written in the SOShipmentEntry extension class, where sOPackageDetailEx is an instance of the 'SOPackageDetailEx' class.

Hayk
  • 46
  • 3
  • Hi Hayk, i am not much clear where to place this code, could you please tell me in which event or which place exactly i need to place this code. I have tried this code SOPackageDetailEx_RowSelected event and SOShipment_Rowpersisted also RowPersisting event but i fail to modify and save the tracking nbr changes. – BhavyaSri Apr 23 '20 at 12:58