0

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.sstatic.net/oCAzi.png
[2]: https://i.sstatic.net/1JKBX.png
[3]: https://i.sstatic.net/Jmvjt.png

1 Answer 1

1

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();
     }    
  }
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Fernando, Its working fine now, I understand that is is a silly mistake, i totally overlooked it. Thanks again. Cheers

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.