Skip to main content

Hello Guys,

 

I wanna simulate the press action on save when updating a field 
i m using this code: 

protected void Choixfournisseurline_Selected_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
{

var row = (Choixfournisseurline)e.Row;
PXCache cache2 = this.Cacheshtypeof(Choixfournisseurline)];
cache2.Persist(row , PXDBOperation.Update);
this.Save.Press();
this.Save.SetPressed(true);
cache.Graph.Actions.PressSave();
//cache2.Graph.Actions.PressSave();

}

but it’s not working! 

 

Thanks.

Hi @SadokHanini  In my opinion, It is NOT recommended to invoke the SAVE action inside the FieldUpdated event, due to caches may not persist properly and always “SAVE” action will be enabled state.

And also, it is better to hear the feedback from the Acumatica support team on this.


Hi @SadokHanini 

 

To invoke save: Base.Actions.PressSave();

It is not advised to do it on the updated fields and remember each save contributes to the ERP transactions count on the license model.

 


Hi @SadokHanini  I also got the same requirement and I reachedout to Acumatica support team on this and below is the response.

Acumatica Support Team Response

First and foremost, saving is not allowed from event handlers.  Acuminator will report it as PX1043 - Changes cannot be saved to the database from event handlers.  If saving is absolutely must for each row, one way will be to do this using javascript. See example below.  Either way, one will still incur ERP transaction with each save. 

 

 <script type="text/javascript">

                        function saveThisRow(s, e) {
                            var ds = px_all"ctl00_phDS_ds"];
                            if (ds != null) {
                                var fld = e.cell.column.dataField;
                                if (fld == "FieldName") ds.executeCallback("Save");
                            }
                        }
                    </script>

                    <px:PXGrid ID="gridPackageDetailSplit" runat="server" SyncPosition="True" SkinID="DetailsInTab" Caption="Contents of Selected Package" Width="100%">
                        <Mode InitNewRow="True"/>
                        <AutoSize Enabled="True"/>
                        <ClientEvents AfterCellUpdate="saveThisRow" />
                        <Levels>

 

Just thought of sharing it here. Hope this helps to you!


Reply