If you are working on peoplecode you may face the below error “Expression of type string is not an object reference”

Expression of type string is not an object reference

If you attempt to set a field value through PeopleCode and the field name is “NAME,” use the shortcut Rowset (Row). Record.Field.Value approach will result in an error. The error message “Expression of type String is not an object reference. (2,48),” is generated when attempting to validate or save the PeopleCode.

root cause of this issue

This occurs because PeopleCode becomes confused with the existence of the Name property in the Field class. To resolve this, you can use the GetField function to access the Field object and set its value, as shown below:

&rec.NAME.Value => error ;


&rec.Label.Value => error ;


&rec.value.Value => error ;

correct way is

&rec.getfield(field.NAME).Value = code accepted

&rec.getfield(field.Label).Value = code accepted

&rec.getfield(field.value).Value = code accepted

You may encounter a similar issue when trying to set the value of other fields, such as LABEL or VALUE, as they are also properties of the Field class.

By admin

Leave a Reply

Your email address will not be published. Required fields are marked *