Solved

Press Save automatically when updating a field

  • 27 August 2021
  • 3 replies
  • 110 views

Userlevel 1

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.Caches[typeof(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.

icon

Best answer by Naveen B 14 October 2021, 14:57

View original

3 replies

Userlevel 7
Badge +9

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.

 

Userlevel 7
Badge +9

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


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2020  Acumatica, Inc. All rights reserved