I have the following acumatic code where I want to fill a datafield with the name UsrSumVolumen and a new column called UsrVolumen is added, adding all the values of that column, the total will be put in UsrSumVolumen.
protected void INLocation_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
{
INLocation row = (INLocation)e.Row;
INLocationExt rowExt = row.GetExtension<INLocationExt>();
if (rowExt != null)
{
// Accede a la nueva columna y realiza acciones adicionales
decimal? valorNuevaColumna = rowExt.UsrVolumen;
decimal? valorNuevaColumna2 = 78;
// Verifica si es necesario actualizar el objeto INSite
INSite orderInCache = Orders.Current as INSite;
if (orderInCache != null)
{
// Ajusta para actualizar el campo usrSumVolumen
Orders.Cache.SetValueExt<INSiteExt.usrSumVolumen>(orderInCache, valorNuevaColumna2);
PXTrace.WriteInformation("EMPEZAMOS - Nuevo valor: " + valorNuevaColumna2.ToString());
// Persiste el cambio
Orders.Cache.Persist(PXDBOperation.Update);
// Presiona el botón Save para asegurar que los cambios se reflejen en la interfaz de usuario
Orders.Cache.Graph.Actions.PressSave();
}
else
{
PXTrace.WriteInformation("orderInCache es nulo");
}
}
else
{
PXTrace.WriteInformation("rowExt es nulo");
}
}
When reviewing the Last Requests, if it brings the requested values but does not insert it in UsrSumVolumen, can you help me solve it?
I also tried this code so that it would add automatically if it does, but only when I modify a grid field
[PXDBDecimal]
[PXUIField(DisplayName="volumen")]
[PXDefault(TypeCode.Decimal, "0.0", PersistingCheck = PXPersistingCheck.Nothing)]
[PXFormula(null, typeof(SumCalc<INSiteExt.usrSumVolumen>))]