Solved

Contant string is obsolete and I have a constant with an array - don't know what to do

  • 10 November 2021
  • 3 replies
  • 361 views

Userlevel 6
Badge +3

I am upgrading someone else’s code that is old.  When using Constant<string> or Constant<string[]> I get a warning that the syntax is obsolete.

I fixed two of the classes, but I cannot figure out how to fix this one

public class IDs : Constant<string[]>

I was able to change Contant<string> in the “Open” class and the “Closed” class by using PX.Data.BQL.BqlString.Constant<Open> and PX.Data.BQL.BqlString.Constant<Closed>

I just don’t know what the syntax is for changing Constant<string[]>. 

Here is the source code 

    public class FDSpecStatusAttribute : PXStringListAttribute
    {
        #region Constants

        //public class Open : Constant<string>
        public class Open : PX.Data.BQL.BqlString.Constant<Open>
        {
            public const string VALUE = "O";
            public const string DISPLAY_NAME = "Open";
            public Open() : base(Open.VALUE) { }
        }

        //public class Closed : Constant<string>
        public class Closed : PX.Data.BQL.BqlString.Constant<Closed>
        {
            public const string VALUE = "C";
            public const string DISPLAY_NAME = "Closed";
            public Closed() : base(VALUE) { }
        }

        public class IDs : Constant<string[]>
        {
            public static readonly string[] VALUE = new string[]
            {
                Open.VALUE,
                Closed.VALUE,
            };
            public IDs() : base(VALUE) { }
        }

Any advice would be appreciated.

Thank you,

Joe Schmucker

icon

Best answer by Naveen Boga 10 November 2021, 20:13

View original

3 replies

Userlevel 7
Badge +17

Thanks a lot @joe21 for the sharing the update :slight_smile:

Userlevel 6
Badge +3

Hi @Naveen B ,

Worked like a charm.  I would never have figured that out in a million years.

Thank you!!

Userlevel 7
Badge +17

Hi @joe21  Can you please verify with below code.

 

    public class TestField : BqlType<IBqlString, string[]>.Constant<TestField>
{
public static readonly string[] stringvalues = new string[]
{
Open.VALUE,
Closed.VALUE,
};
public TestField() : base(stringvalues) { }
}

 

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