Skip to main content
Contributor
Dec 14, 2023 9:58 PM UTC
Solved

Error in BR: Object reference not set to an instance of an object.

Hi, I have the following code that gives me an error: Object reference not set to an instance of an object.

Dim listMbrEntityD As New List(Of Member)

Dim dimpkEntityD As New DimPk(mbrEntityD.DimTypeId, mbrEntityD.DimId)
listMbrEntityD.AddRange(BRApi.Finance.Members.GetBaseMembers(si, dimpkEntityD, mbrEntityD.MemberId))

I have debugged with errorlog but it doesn’t manage to print anything to see the values, any idea how to solve it?

Contributor
Dec 14, 2023 11:10 PM UTC

The reason you got no values in your debug is probably the same reason you're getting the error. Something you're trying to use is not set to anything.

E.g., mbrEntityD, dimpkEntityD, or the result of "BRApi.Finance.Members.GetBaseMembers(si, dimpkEntityD, mbrEntityD.MemberId)"

Check those one by one and I think you'll find it.

4 replies

Contributor
Dec 14, 2023 11:10 PM UTC

The reason you got no values in your debug is probably the same reason you're getting the error. Something you're trying to use is not set to anything.

E.g., mbrEntityD, dimpkEntityD, or the result of "BRApi.Finance.Members.GetBaseMembers(si, dimpkEntityD, mbrEntityD.MemberId)"

Check those one by one and I think you'll find it.

MarcoAuthor
Contributor
Dec 15, 2023 5:32 PM UTC

Hi Daniel, I saw that my empty variable is mbrEntityD, which is extracted in the following way.

Dim mbrEntityD As Member = BRApi.Finance.Members.GetMember(si, dimTypeId.Entity, drAllocRegister("DEntity").ToString)

And the values: Entity - 11201_12207.
Do you know how I can verify the information that getmember returns to me with those values?

Contributor
Dec 18, 2023 1:10 AM UTC

Sorry I'm not quite sure what you mean. My Guess is that 'drAllocRegister("DEntity").ToString' is not returning what you expect though.

Contributor
Dec 19, 2023 5:21 PM UTC

Hi Marco,

Try adding the line below and then run it and check it in the System/Error Log. Then you can check that you're selecting the right member looking to the memberID information.

Good luck

Carlos

 

 

 

BRApi.ErrorLog.LogMessage(si, mbrEntityD.ToString)