user_mat
user_mat

Reputation: 191

Custom fields are not showing updated value when update in field updated event, Why?

I have added custom fields in customization form using the customization form, steps i have added: 1) Go to shipment form and select Transaction Grid. 2) Select Add fields. 3) Select custome and Add 4 fields and save and publish. 4) Add all 4 fields and select used and save. 5) and publish again and all 4 columns are visible. 6) I have added a user fields name Aloow (PXDBBool), UsrPClocation(Location) and UsrPCwarehouse(Site), and i set the below attribute in warehour and location. 7) But on SOSHipLine_InventotyID_FieldUpdate event, i am setting Allow, location, warehouse all 3 values, but values are not showing in Grid, what is the resoon?

#region UsrQCSiteID

    [PXUIField(DisplayName = "PC Warehouse")]      
    [SiteAvail(typeof(SOShipLine.inventoryID), typeof(SOShipLine.subItemID))]       
    [PXUIRequired(typeof(Where<usrAllow, Equal<True>>))]
    [PXUIEnabled(typeof(Where<usrAllow, Equal<True>>))]
    [PXDefault()]
    public virtual int? UsrPCSiteID {
        get; set;
    }
    public abstract class usrPCSiteID:PX.Data.BQL.BqlInt.Field<usrPCSiteID> {
    }

    #endregion UsrPCSiteID

    #region UsrPCLocationID

    [PXUIField(DisplayName = "PC Location")]       
    [SOLocationAvail(typeof(SOShipLine.inventoryID), typeof(SOShipLine.subItemID), typeof(SOShipLineExt.usrPCSiteID), typeof(SOLine.tranType), typeof(SOShipLine.invtMult))]

    [PXUIRequired(typeof(Where<usrQCRequired, Equal<True>>))]
    [PXUIEnabled(typeof(Where<usrQCRequired, Equal<True>>))]
    [PXDefault()]
    public virtual int? UsrPCLocationID {
        get; set;
    }
    public abstract class usrPCLocationID:PX.Data.BQL.BqlInt.Field<usrPCLocationID> {
    }

    #endregion UsrPCLocationID

#region Allow

    [PXDBBool]
    [PXUIField(DisplayName = "Allow")]

    public virtual bool? UsrAllow {
        get; set;
    }
    public abstract class usrAllow:PX.Data.BQL.BqlBool.Field<usrAllow> {
    }

    #endregion

IS SOShipLine allow updating custom values?

Upvotes: 1

Views: 1361

Answers (1)

Fernando
Fernando

Reputation: 433

The steps that you described look correct.

I recreated this scenario locally:

1 - My DAC extension looks as follows:

  public class SOShipLineExt : PXCacheExtension<PX.Objects.SO.SOShipLine>
  {
    #region UsrPCSiteID
    [PXUIField(DisplayName = "PC Warehouse")]      
    [SiteAvail(typeof(SOShipLine.inventoryID), typeof(SOShipLine.subItemID))]       
    public virtual int? UsrPCSiteID {
        get; set;
    }
    public abstract class usrPCSiteID:PX.Data.BQL.BqlInt.Field<usrPCSiteID> {
    }
    #endregion UsrPCSiteID

    #region UsrPCLocationID
    [PXUIField(DisplayName = "PC Location")]       
    [SOLocationAvail(typeof(SOShipLine.inventoryID), typeof(SOShipLine.subItemID), typeof(SOShipLineExt.usrPCSiteID), typeof(SOShipLine.tranType), typeof(SOShipLine.invtMult))]
    public virtual int? UsrPCLocationID {
        get; set;
    }
    public abstract class usrPCLocationID:PX.Data.BQL.BqlInt.Field<usrPCLocationID> {
    }
    #endregion UsrPCLocationID


#region Allow
    [PXDBBool]
    [PXUIField(DisplayName = "Allow")]
    public virtual bool? UsrAllow {
        get; set;
    }
    public abstract class usrAllow:PX.Data.BQL.BqlBool.Field<usrAllow> {
    }
    #endregion
  }

Notes about the DAC Extension:

  • I removed references to PXUIEnabled and PXUIRequired. If you are looking to disable the Site and the Location based on the checkbox's value, I recommend you manage this logic in the RowSelected event. (it may be feasible with your approach but I have not used it before)
  • The PXDefault references were also removed, given that in most cases the Shipment is created directly from the Sales Order page. As you have it right now, the field is mandatory but no default value is being assigned which will cause an error. You have 2 options: 1) indicate the value in the PXDefault() attribute, or 2) Set the property PXPersistingCheck.Nothing.
  • Note that your SOLocationAvail attribute has an error in the 4th parameter. You should use typeof(SOShipLine.tranType) instead of typeof(SOLine.tranType). This was generating an error when the shipment was created from the SO.

2 - My FieldUpdated event looks as follows:

  public class SOShipmentEntry_Extension : PXGraphExtension<SOShipmentEntry>
  {
    protected virtual void SOShipLine_InventoryID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
  {
    if (e.Row == null) return;
    SOShipLine line = (SOShipLine)e.Row;
    SOShipLineExt lineExt = cache.GetExtension<SOShipLineExt>(line);

    if (lineExt != null)
    {
      lineExt.UsrAllow = true;
      lineExt.UsrPCSiteID=154;
      lineExt.UsrPCLocationID=155;        
    }
  }
  }

Notes about the Graph extension:

  • I hard-coded the Warehouse and Location values. I recommend you do the same on your end while testing is being done, just make sure that the IDs exist in your DB, or that you query the CD value and then use its corresponding ID value.

Results:

When the Shipment is created from a SO, the values are being correctly assigned: enter image description here

Upvotes: 1

Related Questions