Setting the value of "NAME" Fields

If you are trying to set the value of a field through PeopleCode and that field happens to be NAME then you will experience the following error when using the shortcut Rowset(Row).Record.Field.Value approach:

&rsExample(1).DERIVED.NAME.Value = "This will error";

Gives the following error when you try to validate/save PeopleCode:

Expression of type String is not an object reference. (2,48)

This is caused by PeopleCode getting confused with the fact that the Field class also has a property, Name. To get around this, use GetField to access the Field object and then set the value like this:

&rsExample(1).DERIVED.GetField(Field.NAME).Value = "This will work";

This is a list of the Field class properties so I assume that other fields such as LABEL or VALUE in your record would give you a similar error.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License