Hi I am trying to create the array of a class and assigning values to it’s fields. My code is like
RecordRef[] referLocation = new RecordRef[1];
referLocation[0].type = RecordType.location;
referLocation[0].internalId = "6";
But I am getting Exception Error : Object reference not set to an instance of an object.
What is wrong in the code?
You have created array of
RecoredRefobjects, but you haven’t created any object inside it.You need to create instance of objects you want to use:
You may also use
object initializer: