I have a custom graph, in this case called MyGraph. The page contains a Form Tab in a similar fashion to the Stocked Items page in which the header is a few fields of my DAC (MyDAC), and a form on the 1st tab is a form of my additional fields. The views, for the sake of discussion, are MyView and MyCurrentView.
On the Stocked Items page, I can set a value in the ItemSettings view (General Settings tab) and then execute an action which also happens to save my user input. In my custom page, the user input of the similar "MyCurrentView" tab is lost when I execute an action. I have reviewed the training material once again for T230 Actions, but I cannot seem to overcome this problem. The code sample below shows 2 simplified methods of how I execute the action "ConvertIt". In both cases during a Debug, both myDAC and myDAC2 contain the stale data, indicating that the view was not updated as expected per CommitChanges in the Button attribute and in the DataSource Callback Command. The user input that is not saved is entered via a field presented to the UI only in MyCurrentView.
The T230 training guide indicates that I should set the AutoCallBack Behavior in the action bar, which appears to be possible for a grid, but not for a form. The example from the training guide is:
<ActionBar>
<CustomItems>
<px:PXToolBarButton Text="Complete">
<AutoCallBack Command="Complete" Target="ds">
<Behavior CommitChanges="True" ></Behavior>
</AutoCallBack>
</px:PXToolBarButton>
</CustomItems>
</ActionBar>
Since I am hanging my action off the Action menu via action.AddMenuAction(convertIt);, I do not seem to have a way to specify the behavior as described in the training guide.
Views Defined
public PXSelect<MyDAC> MyView;
public PXSelect<MyDAC, Where<MyDAC.tagID, Equal<Current<MyDAC.tagID>>>> MyCurrentView;
Action Defined - Method 1
#region convertIt Action
public PXAction<MyDAC> convertIt;
[PXUIField(DisplayName = "My DAC Label", MapEnableRights = PXCacheRights.Update, MapViewRights = PXCacheRights.Select)]
[PXButton(CommitChanges = true)]
public virtual void ConvertIt()
{
this.Save.Press(); // Seems to make no difference in saving the unsaved user entry
MyDAC myDAC = MyView.Current;
MyDAC myDAC2 = MyCurrentView.Current;
** DO THE WORK OF THE ACTION HERE **
}
#endregion
Action Defined - Method 2
#region convertIt Action
public PXAction<MyDAC> convertIt;
[PXUIField(DisplayName = "My DAC Label", MapEnableRights = PXCacheRights.Update, MapViewRights = PXCacheRights.Select)]
[PXButton(CommitChanges = true)]
public virtual IEnumerable ConvertIt(PXAdapter adapter)
{
MyDAC myDAC = MyView.Current;
MyDAC myDAC2 = MyCurrentView.Current;
** DO THE WORK OF THE ACTION HERE **
return adapter.Get();
}
#endregion
ASPX Datasource Defined
<px:PXDataSource ID="ds" runat="server" Visible="True" Width="100%"
TypeName="MyGraph"
PrimaryView="MyView">
<CallbackCommands>
<px:PXDSCallbackCommand CommitChanges="True" Name="ConvertIt" ></px:PXDSCallbackCommand>
</CallbackCommands>
</px:PXDataSource>
In short, user input is lost when I complete my action. I have tried including this.Save.Press() at the beginning of my action, but I already save at the end of my action. Regardless, a Debug does not show my user entered values in the view, although I expected the commit changes on the button and in the data source to commit those changes from the client before proceeding with the action.
What have I left out of the C# code or ASPX page definition that is preventing my UI updates to be applied? Interestingly enough, UI changes in the MyView view ARE applied, but not changes in MyCurrentView unless I literally press the save button manually before selecting the action from the menu.