Reputation: 29
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
Upvotes: 0
Views: 979
Reputation: 433
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();
}
}
Upvotes: 1