Solved

Cómo ejecutar una instrucción desde una variable


Tengo la necesidad de generar varios campos de filtro en un “Form View” y de estos elegirlos todos o solo aquellos que se requieran, la integración de los queries para filtros no me permiten hacer esto (o tal vez no se como), por lo que se me ocurre integrar en una variable la instrucción del Select para el filtro con base en los campos que requiera (desde uno hasta todos). La variable para el Select la puedo integrar pero requiero que algo la ejecute para que se aplique el filtro con base solo en los campos en los que se seleccionó información, Agradeceré si me pueden ayudar a resolver este problema.

icon

Best answer by Naveen Boga 8 June 2021, 19:38

View original

13 replies

Userlevel 7
Badge +17

Hi @arturoromo51 

Dado que este es un tema diferente, ¿podría crear una nueva pregunta para que los usuarios NO se confundan?

Good morning Naveen B, I apologize for distracting you again but we ran into another problem, I would appreciate it if you could help us again.
We are developing a capture in "Form View", I include the image,

In the "Marca" column we must select an element by name and take its key to place it in the corresponding table.
It presents us with 2 problems, the first is that it does not convert long names to its key, it gives us an error that the field is longer than what is defined in the table and it assigns a different key to it; the second problem is that the fields that have an "&" in the name, it removes the ampersan and puts the text in place of the key.
I am attaching the DAC code.

        #region Marca
        public abstract class marca : PX.Data.IBqlField { }

        [PXDBString(20, IsUnicode = true, IsKey = true)]
        [PXDefault()]

        [PXSelector(typeof(Search<CSAttributeDetail.valueID,
              Where<CSAttributeDetail.attributeID, Equal<attributeLaboratorio>,
                  And<CSAttributeDetail.disabled, NotEqual<True>>>>),
              typeof(CSAttributeDetail.valueID),
              typeof(CSAttributeDetail.description),
              typeof(CSAttributeDetail.disabled), 
              SubstituteKey = typeof(CSAttributeDetail.description))]

        [PXUIField(DisplayName = "Marca", Visible = true)]
        public string Marca { get; set; }
        #endregion Marca

In summary the "ValueID" is replaced by the "SubstituteKey-Description" in the table (next image).

 

Userlevel 7
Badge +17

Yes @ray20 Thanks a lot translating and going through.. :) 

Userlevel 6
Badge +5

@Naveen B 
Hello, excellent. Although I do not speak Spanish, but after translation, I get understand most of them.
It should be helpful for others with the same kind of need.

Userlevel 7
Badge +17

 

Perfecto !! Muchas gracias por la actualización.

Naveen B, te agradecemos el apoyo que nos has dado, funcionó perfectamente bien con algunas pequeñas modificaciones, pero realiza exactamente lo que necesitamos. Te incluyo el código final.

Muchas gracias.

 

Userlevel 7
Badge +17
Seguro. @arturoromo51 

Muchas gracias Naveen B, voy a intentar lo que me indicas y te comunico el resultado.

Userlevel 7
Badge +17
Entiendo tu problema. La consulta BQL anterior NO le ayudará a buscar registros.Necesita trabajar en la consulta dinámica BQL en vista delegada. Encuentre el ejemplo a continuación.su vista debe ser: 
public PXSelect <vUSRepTotalE, donde <vUSRepTotalE.anioDoc, Equal <Current <USRepFiltro.anioDoc >>>> DetailReport;
Ver delegado:  
protected virtual IEnumerable detailReport()
{
int[] branchIDs = null;
if (USRepFiltro.Current != null)
{
PXSelectBase<KNECBaseVehicle> objCMD = new PXSelect<vUSRepTotalE, Where<vUSRepTotalE.anioDoc, Equal<Current<USRepFiltro.anioDoc>>>>(this);

if (USRepFiltro.Current.branchID != null)
{
objCMD.WhereAnd<Where<vUSRepTotalE.branchID, Equal<Current<USRepFiltro.branchID>>>>();
}
if (USRepFiltro.Current.profile != null)
{
objCMD.WhereAnd<Where<vUSRepTotalE.profile, Equal<Current<USRepFiltro.profile>>>>();
}
if (USRepFiltro.Current.CustomerType != null)
{
objCMD.WhereAnd<Where<vUSRepTotalE.CustomerType, Equal<Current<USRepFiltro.CustomerType>>>>();
}
if (USRepFiltro.Current.client != null)
{
objCMD.WhereAnd<Where<vUSRepTotalE.client, Equal<Current<USRepFiltro.client>>>>();
}
if (USRepFiltro.Current.brand != null)
{
objCMD.WhereAnd<Where<vUSRepTotalE.brand, Equal<Current<USRepFiltro.brand>>>>();
}

return objCMD.Select();
}
}
 Espero que lo entiendas y me avises si necesitas ayuda.

 

Agradezco tu interés y apoyo.

Mis filtros son los siguientes:

Solo el año es obligado, el resto de los filtros pueden ser seleccionados o no (uno, dos o todos), de tal manera que el query debe integrarse con solo la información seleccionada, actualmente el query se construye con ORs o ANDs, etc, pero no como se requiere, incluyo el query actual:

 public PXSelect<vUSRepTotalE,
            Where<vUSRepTotalE.anioDoc, Equal<Current<USRepFiltro.anioDoc>>, 
                And<vUSRepTotalE.branchID, Equal<Current<USRepFiltro.branchID>>,
                And<vUSRepTotalE.perfil, Equal<Current<USRepFiltro.perfil>>,
                And<vUSRepTotalE.tipoCliente, Equal<Current<USRepFiltro.tipoCliente>>,
                And<vUSRepTotalE.cliente, Equal<Current<USRepFiltro.cliente>>,
                And<vUSRepTotalE.marca, Equal<Current<USRepFiltro.marca
                >>>>>>>
                >> DetalleReporte;

Esto me obliga a seleccionar la información de todos y cada uno de los elementos del filtro, pero, reitero, el query debe conformarse solamente con los filtros seleccionados uno , varios o todos,

Es por esto que consideré integrar una variable con los filtros seleccionados y después ejecutarla, pero no he encontrado un postulado que me permita la ejecución de una variable con la conformación exacta del Select.

Nuevamente agradezco tu apoyo y espero me puedas ayudar.

Userlevel 7
Badge +17
Muchas gracias por la confirmación.¿Podrías por favor dar más detalles sobre tu problema, que estás recibiendo para que pueda profundizar en él y ayudarte en todo lo que pueda?

Su apreciación es correcta salvo que los filtros no son obligatorios, justo porque pueden o no ser seleccionados. Agradezco su apoyo y quedo pendiente.

Userlevel 7
Badge +17

Hi @arturoromo51 ,

A continuación se muestra mi comprensión. ¿Puede revisar y confirmar que mi comprensión es correcta? Ha creado un formulario con varios campos de filtro (campos obligatorios / obligatorios). Según estos filtros, debe buscar los registros y mostrarlos en el formulario. Espero que este sea el requisito. Por favor confirmar.

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 — 2024  Acumatica, Inc. All rights reserved