简体   繁体   中英

Enable Save Button in Acumatica Screen upon Custom Action Button Click

I have created a Custom Action Button in the grid toolbar "Mark All For PO" which marks all check box for grid column "Mark For PO" in the Sales Order screen (SO301000).

After clicking on my Custom button, the save button on the top left corner of the Sales Order screen is not getting enabled and couldn't able to save the changes. Please help me to proceed with my work

Here Goes My Graph Code.....

    public PXAction<SOOrder> markAllForPO;
      [PXButton(CommitChanges = true)]
      [PXUIField(DisplayName = "Mark All For PO", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]

      public virtual IEnumerable MarkAllForPO(PXAdapter adapter)
      {
          foreach (SOLine tran in Base.Transactions.Select())
          {
              if (tran.POCreate == true)
              {
                  tran.POCreate = false;
                  tran.POSource = "";
              }
              else
              {
                  tran.POCreate = true;
                  tran.POSource = INReplenishmentSource.PurchaseToOrder;
              }
          }
          return adapter.Get();
     }
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Following are the supporting images for the question

[1][SO301000=>Sales Order Screen]
[2][DataSource Property of the Action Button from Customization Editor]
[3][Grid Action bar Property of the Action Button]


[1]: https://i.stack.imgur.com/oCAzi.png
[2]: https://i.stack.imgur.com/1JKBX.png
[3]: https://i.stack.imgur.com/Jmvjt.png

You were almost there!

After the value is assigned, you need to invoke the Update() method in order to let the cache know that there is a new version of the the record.

  public class SOOrderEntry_Extension : PXGraphExtension<SOOrderEntry>
  {    
      public PXAction<SOOrder> markAllForPO;
      [PXButton(CommitChanges = true)]
      [PXUIField(DisplayName = "Mark All For PO", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]

      public virtual IEnumerable MarkAllForPO(PXAdapter adapter)
      {
          foreach (SOLine tran in Base.Transactions.Select())
          {
              if (tran.POCreate == true)
              {
                  tran.POCreate = false;
                  tran.POSource = "";
              }
              else
              {
                  tran.POCreate = true;
                  tran.POSource = INReplenishmentSource.PurchaseToOrder;
              }
              Base.Transactions.Update(tran); //Cache is updated
          }
          return adapter.Get();
     }    
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM