Solved

Error en Selector cambia Descripción por Valor en la Tabla


Good morning, 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).

icon

Best answer by arturoromo51 11 June 2021, 03:29

View original

5 replies

Userlevel 7
Badge +17

Hi @arturoromo51,

Could you please clarify below point?

  • why do you want to make the Marca field as Primary Key field in that grid.

 

Good morning, the "Marca" field is not the primary key, it is made up of all the previous fields plus the "Brand" and is a Selector.
We have already solved the problem of the correct registration of the "Marca", it gives us the correct password, we only have to know with which instruction we prevent it from removing the "&" symbols contained in the description.
The code in the DAC was as follows:

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

        [PXDBString(60, IsUnicode = true, IsKey = true)]
        [PXDefault()]
        [PXUIField(DisplayName = "Marca", Visible = true)]

        [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),
              DescriptionField = typeof(CSAttributeDetail.valueID))]

        public string Marca { get; set; }
        #endregion Marca
 

 

Userlevel 7
Badge +17

I just verified with this selector and observed it is working for me. Please find the screenshots for reference. I’m NOT sure why it is not showing for you.

 

 

 

Thank you very much Naveen B, we solved the problem, we added one more column and in one we put the key and in the other the description, as shown on the screen.

The code is the following:

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

        [PXDBString(10, IsUnicode = true, IsKey = true)]
        [PXDefault()]
        [PXUIField(DisplayName = "Marca", Visible = true)]

        [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.valueID),
              DescriptionField = typeof(CSAttributeDetail.description))]

        public string Marca { get; set; }
        #endregion Marca


        #region MarcaDesc
        public abstract class marcaDesc : PX.Data.IBqlField { }

        // Acuminator disable once PX1030 PXDefaultIncorrectUse [Justification]
        [PXDBString(60, IsUnicode = true)]
        [PXUIField(DisplayName = "Marca Descrip.", Visible = true, Enabled = false)]

        [PXFormula(typeof(Selector<marca, CSAttributeDetail.description>))]
        public string MarcaDesc { get; set; }
        #endregion MarcaDesc

 

Thank you so much, we'll be in touch.

Userlevel 7
Badge +17

Sure.. thanks for sharing the update.

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