Skip to main content
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).

Best answer by arturoromo51

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.

View original
Did this topic help you find an answer to your question?

5 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3381 replies
  • June 10, 2021

Hi @arturoromo51,

Could you please clarify below point?

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

 


  • Author
  • Jr Varsity II
  • 10 replies
  • June 10, 2021

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
 

 


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3381 replies
  • June 10, 2021

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.

 

 

 


  • Author
  • Jr Varsity II
  • 10 replies
  • Answer
  • June 11, 2021

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.


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3381 replies
  • June 11, 2021

Sure.. thanks for sharing the update.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings