Skip to main content

Hi Expert.

I try disale field So Notes depends on the condition of the shipment  in below:

I try set break point at:

PXUIFieldAttribute.SetEnabled(cache, row, true);

                        PXUIFieldAttribute.SetEnabled<SOOrderExt.usrSoNote>(cache, row, true);

 

break point ok, program touch here.

 protected void SOOrder_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected InvokeBaseHandler)

        {

            InvokeBaseHandler?.Invoke(cache, e);

            var row = (SOOrder)e.Row;

            if (row != null && row.OrderNbr != null)

            {

                Base.Document.Cache.AllowUpdate = true;

                Base.Transactions.Cache.AllowUpdate = true;

                SOOrderShipment ship = PXSelect<SOOrderShipment, Where<SOOrderShipment.orderNbr, Equal<Required<SOOrderShipment.orderNbr>>>>.Select(Base, row.OrderNbr.Trim());

                if (ship != null && ship.ShipmentNbr != null)

                {

                    SOShipment shipment = PXSelect<SOShipment, Where<SOShipment.shipmentNbr, Equal<Required<SOShipment.shipmentNbr>>>>.Select(Base, ship.ShipmentNbr.Trim());

                    if (shipment != null && shipment.Status != null && !ConstantsSO.SHIP_STATUS_OPEN.Equals(shipment.Status))

                    {

                        PXUIFieldAttribute.SetEnabled(cache, row, false);

                        PXUIFieldAttribute.SetEnabled<SOOrderExt.usrSoNote>(cache, row, false);

                    }

                    else

                    {

                        PXUIFieldAttribute.SetEnabled(cache, row, true);

                        PXUIFieldAttribute.SetEnabled<SOOrderExt.usrSoNote>(cache, row, true);

                    }

                }

                else

                {

                    PXUIFieldAttribute.SetEnabled(cache, row, true);

                    PXUIFieldAttribute.SetEnabled<SOOrderExt.usrSoNote>(cache, row, true);

                }

            }

        }

 

but this field still enable

 

Can you help me? Thank you so much.

Dear @Vignesh Ponnusamy and All. I enable aboth by code and edit workflow, it work ok. Thank everyone so much. Have a good day!


@thanhaim,

To enable the field apart from the code you need to enable in the workflow extension as well. From your note, I assume you want to enable the custom field when the document is in Shipping status and based on the status of the Shipment line. 

As you already have in the RowSelected event you can do the logic check there, enable in the code. In addition to it, you just enabled the field in the TR workflow extension(as the document type is TR here). Below is the screenshot of the options for your reference,

 

 

 

As an example, I have added Description field and made sure it is not Disabled. Similarly, you can add the custom field in the Shipping state and uncheck the Disabled checkbox. Hope that helps.! 

Thanks,


Reply