Forum Discussion

Marco's avatar
Marco
Contributor II
2 years ago

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?

  • 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.

  • DanielWillis's avatar
    DanielWillis
    Valued Contributor

    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.

    • Marco's avatar
      Marco
      Contributor II

      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?

      • DanielWillis's avatar
        DanielWillis
        Valued Contributor

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

  • 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)