How to retrieve a list of labels for an object?

Post your questions regarding using the Vault and Fortress API in your programs.

Moderator: SourceGear

Post Reply
joacim
Posts: 21
Joined: Wed Jan 28, 2009 6:04 am
Location: Interactive Medica

How to retrieve a list of labels for an object?

Post by joacim » Thu Jan 29, 2009 5:04 pm

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.

shannon

Re: How to retrieve a list of labels for an object?

Post by shannon » Thu Jan 29, 2009 6:53 pm

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

joacim
Posts: 21
Joined: Wed Jan 28, 2009 6:04 am
Location: Interactive Medica

Re: How to retrieve a list of labels for an object?

Post by joacim » Fri Jan 30, 2009 7:17 am

Thank you it works perfectly. Don't I have to call the EndLabelQuery() method?

shannon

Re: How to retrieve a list of labels for an object?

Post by shannon » Fri Jan 30, 2009 8:45 am

Sorry, yes you should.

joacim
Posts: 21
Joined: Wed Jan 28, 2009 6:04 am
Location: Interactive Medica

Re: How to retrieve a list of labels for an object?

Post by joacim » Mon Feb 02, 2009 5:49 am

Is there a limit on the number of labels an object can have in Vault?

joacim
Posts: 21
Joined: Wed Jan 28, 2009 6:04 am
Location: Interactive Medica

Re: How to retrieve a list of labels for an object?

Post by joacim » Thu Mar 12, 2009 2:17 pm

joacim wrote:Is there a limit on the number of labels an object can have in Vault?
Still wondering... :)

lbauer
Posts: 9736
Joined: Tue Dec 16, 2003 1:25 pm
Location: SourceGear

Re: How to retrieve a list of labels for an object?

Post by lbauer » Mon Mar 16, 2009 7:57 am

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

Post Reply