1
votes

I have a problem in Acumatica. I have created a trigger on InventoryItem table to insert the inserted records to my customized table.

The problem is, whenever I try to save new stock items in Acumatica, it does not reflect the correct last-saved data of the stock item. The details in the general settings tab are incorrect. I need to close the screen and reopen to be able to see the correct data.

Can someone please help me with regards to how can I get a refreshed stock item screen immediately after saving. Or is there a bug in Acumatica whenever there is a customized trigger?

3

3 Answers

1
votes

I haven't checked the issue you mentioned about not refreshing the information, but if you need to forcefully refresh the screen after saving the record

  • Override persist
  • call the base action
  • create a new instance of graph
  • search for the record to set as current of the header cache
  • throw new redirect required exception

so the code might look as below [Might require Modification]

[PXOverride]
public void Persist(Action persit)
{
 persit();// this will call base Persist();
 InventoryItemMaint grp = PXGraph.CreateInstance<InventoryItemMaint>();
 InventoryItem inv = PXSelect<InventoryItem, Where<InventoryItem.inventoryCD, Equal<Required<InventoryItem.inventoryCD>>>>.Select(grp, this.Base.Item.Current.InventoryCD.Trim());
 if (inv != null && inv.InventoryID.HasValue)
 {
    grp.Item.Current = grp.Item.Search<InventoryItem.inventoryID>(inv.InventoryID);
    throw new PXRedirectRequiredException(grp, "Reloading Item");
 }
}

If you dont want the whole screen to be refreshed, instead of throwing the exception you can just refresh the required view method suggested by other user(Yura Zaletskyy) on this post.

1
votes

Let's say your grid is binded to view PayRollsDetails. Then you can use following code to refresh your grid:

PayRollsDetails.View.Cache.Clear();
PayRollsDetails.View.Cache.ClearQueryCache();
0
votes

You can try the select method. For example: this is the item setting data view in Acumatica source code (you can use the explore source code page)

[PXViewName(Messages.InventoryItem)]
public PXSelect<InventoryItem, Where<InventoryItem.inventoryID, Equal<Current<InventoryItem.inventoryID>>>> ItemSettings;

Through customization (I assume you use AEF), add select method for this data view

[PXViewName(Messages.InventoryItem)]
public PXSelect<InventoryItem, Where<InventoryItem.inventoryID, Equal<Current<InventoryItem.inventoryID>>>> ItemSettings;

protected virtual IEnumerable itemSettings()
{
    return new PXSelect<InventoryItem, Where<InventoryItem.inventoryID, Equal<Current<InventoryItem.inventoryID>>>>(Base).Select();
}

Sometimes I use sql store procedure to insert data to my table, the select method is helpful for reloading screen with inserted data.