Returns the member ID of a dimension member. The member’s label is passed and its ID is returned.
<IHsvTreeInfo>.GetItemID(bstrLabel)
The following Visual Basic 6 example defines a custom function named GetMemberID that returns the member ID of a dimension member. The GetMemberID function has the following arguments:
The lDimID argument takes the ID of the applicable dimension, which is passed to the Dimension property to set an IHsvTreeInfo object reference for the applicable dimension. (For a listing of valid dimension IDs, see Dimension ID Constants.)
The sMemLabel argument takes the label of the dimension member, which is passed to GetItemID.
The member ID returned by GetItemID is set as the GetMemberID function’s return value.
Function GetMemberID(lDimID As Long, sMemLabel As String) As Long Dim cTreeInfo As IHsvTreeInfo 'g_cMetadata is an HsvMetadata object reference. Set cTreeInfo = g_cMetadata.Dimension(lDimID) GetMemberID = cTreeInfo.GetItemID(sMemLabel) End Function
Following is a C# example that implements the custom GetMemberID function.
public int getMemberId(short shDimId, string sLabel) { //gets a dimension member ID from a member label HSVMETADATALib.HsvMetadata cMetadata = (HSVMETADATALib.HsvMetadata)g_cSession.Metadata; //HSVMETADATALib.IHsvTreeInfo cTreeInfo = cMetadata.Dimension(lDimId); //use accessor method for Dimension HSVMETADATALib.IHsvTreeInfo cTreeInfo = (HSVMETADATALib.IHsvTreeInfo) cMetadata.get_Dimension(shDimId); int iId = cTreeInfo.GetItemID(sLabel); return iId; }
The GetMemberID function defined in this example is called by many other examples throughout this book, such as the Example for GetCell. |