Forum Discussion

Former_Member's avatar
Former_Member
Ideator I
8 years ago

How to query for the latest generation of items that the user has access to?

Hi, I would like to ignore the "is_current" property when querying for items, and instead return the latest generation of each item that the user has access to (i.e. permission to "get"). For instance, since the permission_id can change for a given config_id, the user might not be able to access the vary latest:  Can I do this in AML? Or do I need to do some SQL magic instead? Would be great if somebody could help me implement a method that does this. Or at least show me how I should approach the problem.  

3 Replies

  • Ah, cool! What magic does <generation condition="gt">0</generation> do? I mean, how does applying a condition on generation change the behavior of is_current?
  • Hi Kalle, Typically AML queries only return the most current versions of items, but you can override this functionality by adding a property like below to your query. <generation condition="gt">0</generation> By manually querying for the generation like this, all versions of the items will be returned. You could then perform a search for specific permission_ids with something like below. <permission_id condition="in">95475AE006E7415794BDC93808DC04D2,A43FE707C3C54C90AD660D27A81AC58D</permission_id> Chris
    Christopher Gillis Aras Labs Software Engineer
  • I guess it's possible to do something like:
    SELECT P1.*
     FROM [InnovatorSample].[innovator].[PART] AS P1
     WHERE GENERATION = (
     SELECT MAX(GENERATION) FROM [InnovatorSample].[innovator].[PART] AS P2
     WHERE PERMISSION_ID IN ('95475AE006E7415794BDC93808DC04D2', 'A43FE707C3C54C90AD660D27A81AC58D') AND P1.CONFIG_ID = P2.CONFIG_ID)
     ORDER BY P1.NAME