Skip to main content
Solved

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

  • November 10, 2021
  • 3 replies
  • 486 views

Joe Schmucker
Captain II
Forum|alt.badge.img+2

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

Best answer by Naveen Boga

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) { }
        }

 

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

3 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3407 replies
  • Answer
  • November 10, 2021

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) { }
        }

 


Joe Schmucker
Captain II
Forum|alt.badge.img+2
  • Author
  • Captain II
  • 454 replies
  • November 10, 2021

Hi @Naveen B ,

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

Thank you!!


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

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


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