Skip to main content

Hello,

I have a custom long run in a IEnumerable action and upon return, the Shipping_Contact fields return as disabled. Currently, I have to manually cancel the order to re-enable them- see below for my code:

public PXAction<SOOrder> CustomAction;
[PXProcessButton(CommitChanges = true, Category = "Processing", DisplayOnMainToolbar = true, Connotation = PX.Data.WorkflowAPI.ActionConnotation.Success)]
[PXUIField(DisplayName = "Custom Action", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
public virtual IEnumerable customAction(PXAdapter adapter)
{

List<SOOrder> list = new List<SOOrder>() { Base.Document.Current };

Base.Persist();

PXLongOperation.StartOperation(Base, delegate (){ /*Logic*/ });

return list;

}

To say I tried it.. I have tried adding Base.Cancel.Press(), Base.Shipping_Contact.View.RequestRefresh(); right before returning the list but as I expected, this does not work. I figure this is because the IEnumerable return overrides anything I would do to the screen and it is just returning the current order by the keys.. this is build 23.117.0021.

This is the value before:


This is the value after:


Please let me know if there is anything I am doing wrong or some logic I can tap into to prevent this from happening.
 

Have you tried returning adapter.Get()? Not sure that would make any difference, but maybe worth a shot.


Hey @darylbowman- I did try that as well to no avail.


Hi @rhooper91 were you able to find a solution? Thank you!


Hello @rhooper91 ,

I am late to this discussion. Please try the below code if you still need it. I tested it locally and worked for me and no effect on the Address panel after processing.

public PXAction<SOOrder> CustomAction;
>PXUIField(DisplayName = "Custom Action", MapEnableRights = PXCacheRights.Select)]
>PXProcessButton(Category = "Processing", DisplayOnMainToolbar = true, Connotation = PX.Data.WorkflowAPI.ActionConnotation.Success)]
protected virtual IEnumerable customAction(PXAdapter adapter)
{
List<SOOrder> list = adapter.Get<SOOrder>().ToList();
Base.Save.Press();
var currentDoc = Base.Document.Current;

PXLongOperation.StartOperation(Base, () =>
{
/* Code Here*/
});

return list;
}

 


Hey @hdussa -

I appreciate the insight. I just had a moment to crack the code back open and try your suggestion- replacing the save action with the ui effective save and putting it in a different place in the code and I still get the same thing. I am calling .Persist() in my long run operation due to allocation reasons (I have to delete lines and persist to allow for creating new ones w/ allocated quantities) so that might have something to do with it. Right now, my work around is to just press ‘Cancel’ and it re-opens.. so not a big deal.. but kind of annoying.

I will reach out if I have an a-ha moment.


Reply