Is this code part of a class or static function?
I need the whole code file to provide a correct assessment:
- Try checking that all your code is in a method of a class.
- If above exists, then you add this code outside a namespace.
Software Engineer
ASKER
That is all of the code, Miguel. It is within a script editor window used by a third-party add-on for an ERP application.
ste5an
It's pretty simple, just start with one test. Remove all other code as well as dead code. E.g. what happens when your script only consists of four lines:
if (po.val_Required_Date == Genframe4.Utils.DateTimeExtensions.MinValue){ e.Cancel = true; return "Required Date is a required field.";}
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Software Engineer
ASKER
Everything worked fine today, until I added the code in the line numbers indicated.
That was when I got the error, upon clicking "Compile".
ste5an
Well, indexers in C# are not separated by a dot from the object identifer.
But you should learn how to debug code.
Chris Stanyon
In C#, you access Object members using the dot syntax:
instance.member
You access Array keys using the square brackets:
array["key"]
On the lines that you're getting the errors, you're mixing the 2:
pli.["xRequiredDate"]
In your code, sometimes you're treating pli as an array and sometimes you're treating it as an object. Depending on your types, choose one or the other:
Unlimited question asking, solutions, articles and more.
Software Engineer
ASKER
Hi Chris:
Thank you, for your quick response!
Unfortunately, the software package that I'm conducting this code in requires those brackets only because fields such as the Required Date are user-defined fields that I created in that package. Those brackets don't reference an array the same way that standard C# references an array.
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
I need the whole code file to provide a correct assessment:
- Try checking that all your code is in a method of a class.
- If above exists, then you add this code outside a namespace.