<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Retrieving Groups and their contents via API in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Retrieving-Groups-and-their-contents-via-API/m-p/166077#M38158</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Pretty straight-forward... If the group in question has any fields (or possibly just the active field) that is made up from an expression (such as building a value representing the values that go into that data point, for e.g.), rather than just plain old fields, it can't return the active field. I guess because it returns a value of type Field, which an expression doesn't count as?&lt;/P&gt;&lt;P&gt;Quite stumped now... I have an idea, but it's one of those based on a lot of assumption at runtime. I'll report back once I've implemented it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 28 May 2010 10:18:21 GMT</pubDate>
    <dc:creator />
    <dc:date>2010-05-28T10:18:21Z</dc:date>
    <item>
      <title>Retrieving Groups and their contents via API</title>
      <link>https://community.qlik.com/t5/QlikView/Retrieving-Groups-and-their-contents-via-API/m-p/166075#M38156</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;My end goal is to be able to set a cycle button, via the API, so that when I automate the production of static charts (I know...), I can change some of the aspects of the charts.&lt;/P&gt;&lt;P&gt;So far, I've got a fairly decent program, written in C#, that uses the API to get hold of valid values for a selection of Fields, get the charts in the Qlikview file, and allow the user to specify a set of filters (built up from the Fields) against charts, and export an image to a jpg. It works a charm right now, but there are some charts where I need to flip a cycle button.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;So I thought I'd start by simply retrieving the Groups collection, and take a look at what we've got. I should know now that collections don't happen in the API!&lt;/P&gt;&lt;P&gt;The SDK gives the following code:&lt;/P&gt;&lt;P style="font-style: italic"&gt;&lt;CODE&gt;groups=ActiveDocument.GetGroups&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/I&gt;&lt;I&gt;&lt;CODE&gt;groups(0).AddField "Account"&lt;/CODE&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;Of course, writing this in .NET, I need to type &lt;I&gt;groups&lt;/I&gt;; at the moment &lt;I&gt;ActiveDocument.GetGroups&lt;/I&gt; returns an object. The SDK says that this object is a variant, of which there is no equivalent in .NET, and I have no idea how I get to the different elements of this array!&lt;/P&gt;&lt;P&gt;Any help gratefully appreciated.&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;P style="font-style: italic"&gt;&lt;BR /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 26 May 2010 16:43:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Retrieving-Groups-and-their-contents-via-API/m-p/166075#M38156</guid>
      <dc:creator />
      <dc:date>2010-05-26T16:43:51Z</dc:date>
    </item>
    <item>
      <title>Retrieving Groups and their contents via API</title>
      <link>https://community.qlik.com/t5/QlikView/Retrieving-Groups-and-their-contents-via-API/m-p/166076#M38157</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK, I'm a little further down the line, in that I can now get a list of the groups, thus (please excuse the hideous formatting!):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;object[]g = (object[])doc.GetGroups(); //get an object array of the groups. Each one of the items is a Group&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So my real goal here is to work out what the active field is in a group, and then cycle through the group until my required field is active. Now I can get at the groups, I can now make the process a bit more user-configurable (I know, they're basically doing what they'd do, but via the API, but they do this bit once, and it applies across every combination of things they want to produce static charts for!)&lt;/P&gt;&lt;P&gt;For my next trick, I thought I'd wander through the groups collection, and find my group. I realise this is as easily achieved by doing &lt;I&gt;doc.GetGroup(groupName)&lt;/I&gt;, but I've had no joy with that either...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;&lt;BR /&gt;Groupgg ;&lt;BR /&gt;Fieldff ;&lt;BR /&gt;for(int i = 0; i &amp;lt; g.Length; i++)&lt;BR /&gt;{&lt;BR /&gt; gg = (Group)g[ i ]; //cast the element in question to type Group&lt;BR /&gt; if(gg.Name == groupName)&lt;BR /&gt; {&lt;BR /&gt; ff = gg.GetActiveField(); //THIS DOESN'T DO ANYTHING! IT RETURNS null!&lt;BR /&gt; }&lt;BR /&gt;}&lt;BR /&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;So now I'm off to find out whether it's the group I've chosen to examine, or a method that simply doesn't do anything. I'm betting on the latter...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Wish me luck. I'm sure going to need it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tom&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 May 2010 09:58:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Retrieving-Groups-and-their-contents-via-API/m-p/166076#M38157</guid>
      <dc:creator />
      <dc:date>2010-05-28T09:58:02Z</dc:date>
    </item>
    <item>
      <title>Retrieving Groups and their contents via API</title>
      <link>https://community.qlik.com/t5/QlikView/Retrieving-Groups-and-their-contents-via-API/m-p/166077#M38158</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Pretty straight-forward... If the group in question has any fields (or possibly just the active field) that is made up from an expression (such as building a value representing the values that go into that data point, for e.g.), rather than just plain old fields, it can't return the active field. I guess because it returns a value of type Field, which an expression doesn't count as?&lt;/P&gt;&lt;P&gt;Quite stumped now... I have an idea, but it's one of those based on a lot of assumption at runtime. I'll report back once I've implemented it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 May 2010 10:18:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Retrieving-Groups-and-their-contents-via-API/m-p/166077#M38158</guid>
      <dc:creator />
      <dc:date>2010-05-28T10:18:21Z</dc:date>
    </item>
    <item>
      <title>Retrieving Groups and their contents via API</title>
      <link>https://community.qlik.com/t5/QlikView/Retrieving-Groups-and-their-contents-via-API/m-p/166078#M38159</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;** Caveat: This will only work if the groups are changed when the document opens, and not again, although it might be possible to advance through groups, but synchronisation might be a problem **&lt;/P&gt;&lt;P&gt;The way I found to do this, and it's not great, because it is like going through the cycle buttons blind, is as follows:&lt;/P&gt;&lt;P&gt;You can always access the labels collection of the group, thus:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;&lt;BR /&gt;IGroupProperties gp = doc.GetGroup(groupName).GetProperties();&lt;BR /&gt;object[] lbls = (object[])gp.Labels;&lt;BR /&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;Based on the fact that when the Qlikview file opens every group is set at the first field in the group, and the label collection is in the same order, we should be able to loop through the labels, checking whether the label text matches the field we want, and then mimicking a click on the cycle button if it's not.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;&lt;BR /&gt;&lt;BR /&gt;for (int i = 0; i &amp;lt; lbls.Length; i++)&lt;BR /&gt;{&lt;BR /&gt; if (lbls[ i ].ToString() == labelMatch)&lt;BR /&gt; {&lt;BR /&gt; return;&lt;BR /&gt; }&lt;BR /&gt; doc.GetGroup(groupName).Cycle(1);&lt;BR /&gt;}&lt;BR /&gt;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;Like I say, it's not a perfect solution; I'd like to be able to cycle through until I could be sure the active field was the field in question. I guess what I'm looking for is an GetActiveLabel() method, or perhaps GetActiveExpression()...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 May 2010 11:03:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Retrieving-Groups-and-their-contents-via-API/m-p/166078#M38159</guid>
      <dc:creator />
      <dc:date>2010-05-28T11:03:30Z</dc:date>
    </item>
  </channel>
</rss>

