How to retrieve a list of labels for an object?
Moderator: SourceGear
How to retrieve a list of labels for an object?
I was wondering how I would go about to get a list of the labels assigned to a Vault folder? I'm really just interested in the labels directly assigned to the folder, not any inherited labels. I've done some investigation and I assume I need to use the BeginLabelQuery(), the GetLabelQueryItem_Main(), and the EndLabelQuery() methods however I'm not clear on the parameter lists of these methods. Any examples would be highly appreciated.
Re: How to retrieve a list of labels for an object?
I think this code snippet should cover it, but let me know if something is still unclear. If you called GetLabelQueryItems_Recursive, you'd pass rowsRetRecur instead of rowsRetMain.
Code: Select all
long objId = RepositoryUtil.FindVaultTreeObjectAtReposOrLocalPath("$").ID;
string qryToken;
long rowsRetMain;
long rowsRetRecur;
ServerOperations.client.ClientInstance.BeginLabelQuery(
"$",
objId,
true, // get recursive
true, // get inherited
true, // get file items
true, // get folder items
1000, // max rows to return
out rowsRetMain,
out rowsRetRecur,
out qryToken);
VaultLabelItemX[] labelItems;
// start at 0 and go to the end (rowsRetMain)
ServerOperations.client.ClientInstance.GetLabelQueryItems_Main(
qryToken, 0, (int) rowsRetMain, out labelItems);
Re: How to retrieve a list of labels for an object?
Thank you it works perfectly. Don't I have to call the EndLabelQuery() method?
Re: How to retrieve a list of labels for an object?
Is there a limit on the number of labels an object can have in Vault?
Re: How to retrieve a list of labels for an object?
Still wondering...joacim wrote:Is there a limit on the number of labels an object can have in Vault?
Re: How to retrieve a list of labels for an object?
There's no specific limit, but labels will add to the size of your database, so make sure you have adequate disk space.
Linda Bauer
SourceGear
Technical Support Manager
SourceGear
Technical Support Manager