fiogf49gjkf0d Hello everybody,
I have a little issue at the moment of saving.
I replaced the builtin Save business rule, for a custom one because I needed some data validation before saving. Thats working OK, the thing is that when I correct the data that is throwing the validation exception, the validation keeps poping up. The old data stay saved on the entity object and I dont know how to refresh it or something.
Here is the code. It is in a button on a toolbar:
<p>public static void btnGuardar_OnClickStep( IDetalleAgencia form, EventArgs args) { IAgencia agencia = form.CurrentEntity as IAgencia; string CUIT = agencia.Account.AccountX.Docnumero.ToString(); string tipo = agencia.Account.AccountX.Doctipo.ToString().Trim(); Sage.Platform.WebPortal.Services.IPanelRefreshService refresh = form.WorkItem.Services.Get<Sage.Platform.WebPortal.Services.IPanelRefreshService>(); if (tipo == "CUIT") { try { int num = int.Parse(CUIT); if (CUIT.Substring(0,2) == "20" || CUIT.Substring(0,2) == "23" || CUIT.Substring(0,2) == "24" || CUIT.Substring(0,2) == "27" || CUIT.Substring(0,2) == "30" || CUIT.Substring(0,2) == "33" || CUIT.Substring(0,2) == "34") { if (agencia.ValidarCUIT()) { agencia.Save(); refresh.RefreshMainWorkspace(); } else { throw new Sage.Platform.Application.ValidationException("CUIT - Inválido, por dígito verificador." + CUIT); } } else { throw new Sage.Platform.Application.ValidationException("CUIT - Invalido, comienzo incorrecto." + CUIT); } } catch (Exception e) { throw new Sage.Platform.Application.ValidationException("CUIT - Inválido, no es un número." + CUIT); refresh.RefreshMainWorkspace(); } } }
|