Code Snippet: Generic, Reusable Code to Get All Identities In a Group
Hello everyone, Here is a code snippet to retrieve all identities in a identity (group) recursively. As I faced this requirement multiple times, and Innovator not having a standard function for it, I decided to create it myself. [embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:609a024f-f7a3-41b9-8f03-c991fd46edd3:type=csharp&text=%2F%2F%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%0A%2F%2F%20%5BAUTHOR%5D%3A%20SOFTWERK%3A%20D.%20Theoden%0A%2F%2F%20%5BCREATED%20ON%5D%3A%202024-01-18%0A%2F%2F%20%5BMETHOD%5D%3A%20aer_get_identities_in_group.cs%0A%2F%2F%20---------------------------------------------------------------------------------------%0A%2F%2F%20%5BDESCRIPTION%5D%3A%0A%2F%2F%20Generic%2C%20reusable%20code%20to%20get%20all%20users%20in%20a%20group.%20Implements%20trick%20to%20use%20functions%0A%2F%2F%20inside%20Aras%20Innovator%20server%20methods.%0A%2F%2F%20---------------------------------------------------------------------------------------%0A%2F%2F%20%5BCHANGES%5D%3A%0A%2F%2F%20REF%20NO%20%20%20%20%20%20%20DATE%20%20%20%20%20%20%20%20%20%20%20%20WHO%20%20%20%20%20%20%20%20%20%20%20%20%20DETAIL%0A%2F%2F%20%23001%20%20%20%20%20%20%20%20%202024-01-22%20%20%20%20%20%20D.%20Theoden%20%20%20%20%20%20Initial%20version.%0A%2F%2F%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%2A%0A%0A%2F%2F%20Define%20parameters%0AItem%20item%20%3D%20this%3B%0AInnovator%20inn%20%3D%20item.getInnovator%28%29%3B%0AList%3Cstring%3E%20userIdentities%20%3D%20new%20List%3Cstring%3E%28%29%3B%0A%0AItem%20initialIdentity%20%3D%20inn.getItemById%28%22Identity%22%2C%20%22804E11705E1D4E98AEBBDB8E9AFC0B7C%22%29%3B%20%2F%2F%20Your%20existing%20logic%20to%20get%20a%20%28group%29%20identity%0AProcessIdentity%28initialIdentity%2C%20inn%2C%20userIdentities%29%3B%0A%0A%2F%2F%20Rest%20of%20your%20logic%20here.%20All%20recursively%20found%20identities%20are%20now%20stored%20in%20userIdentites%20array.%20%0Areturn%20this%3B%0A%0A%7D%20%2F%2F%20Allow%20functions%20in%20server%20methods%20Part%20A%3A%20extra%20curly%20brace.%20This%20is%20NOT%20a%20mistake.%0A%0A%2F%2F%20Function%20to%20recursively%20process%20identities%20and%20add%20unique%20users%20to%20the%20list%0Avoid%20ProcessIdentity%28Item%20identity%2C%20Innovator%20inn%2C%20List%3Cstring%3E%20userIdentities%29%20%7B%0A%20%20%20%20if%20%28identity.getProperty%28%22is_alias%22%2C%20%22%22%29%20%3D%3D%20%221%22%29%20%7B%0A%20%20%20%20%20%20%20%20%2F%2F%20Add%20user%20identity%20if%20it%27s%20unique%0A%20%20%20%20%20%20%20%20string%20userId%20%3D%20identity.getID%28%29%3B%0A%20%20%20%20%20%20%20%20if%20%28%21userIdentities.Contains%28userId%29%29%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20userIdentities.Add%28userId%29%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%20else%20%7B%0A%20%20%20%20%20%20%20%20%2F%2F%20Process%20group%20members%0A%20%20%20%20%20%20%20%20Item%20groupMembers%20%3D%20inn.applyAML%28%22%3CAML%3E%3CItem%20type%3D%27Member%27%20action%3D%27get%27%20select%3D%27related_id%27%3E%3Crelated_id%3E%3CItem%20type%3D%27Identity%27%20action%3D%27get%27%3E%3C%2FItem%3E%3C%2Frelated_id%3E%3Csource_id%3E%22%20%2B%20identity.getID%28%29%20%2B%20%22%3C%2Fsource_id%3E%3C%2FItem%3E%3C%2FAML%3E%22%29%3B%0A%20%20%20%20%20%20%20%20int%20memberCount%20%3D%20groupMembers.getItemCount%28%29%3B%0A%20%20%20%20%20%20%20%20for%20%28int%20j%20%3D%200%3B%20j%20%3C%20memberCount%3B%20j%2B%2B%29%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20Item%20member%20%3D%20groupMembers.getItemByIndex%28j%29%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20Item%20memberIdentity%20%3D%20member.getRelatedItem%28%29%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20ProcessIdentity%28memberIdentity%2C%20inn%2C%20userIdentities%29%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%7D%0A%0A%2F%2F%20Any%20more%20functions%20of%20your%20own...%0A%0Avoid%20enableFunctionsInMethods%28%29%20%7B%20%2F%2F%20Allow%20functions%20in%20server%20methods%20Part%20B%3A%20opening%20dummy%20method.%20This%20is%20NOT%20a%20mistake.] I hope this saves you some time too. All the best from Almelo. Daan0Views2likes0CommentsHow to use Visual Studio Code 2022 for Coding Methods
I am new to Aras development, and I'd like to use Visual Studio Code 2022 ("VS Code") for coding Innovator methods. I found the ArasVSMethodPlugin project on GitHub, and its change log indicates that support for VS Code 2022 was added in version 1.21. However, when I attempt to load the plugin using the .vsix file from the Aras Innovator Method Plugin on Open VSIX (which was updated 3 months ago), I get a message telling me that Code can't find a package.json file that its expecting. Details about the package.json file for a VS Code extension can be found on this Publishing Extensions page. I was wondering if anyone else was using VS Code 2022 for coding methods and if they might have any additional information about how to get it working. Thanks in advance for any/all assistance.0Views1like1Comment'The given key '()' was not present in the dictionary.' Error
Wanted to provide a solution to an old post on here. In our situation, when this item presented, it was a missing item from one of the float codes, specifically for updates. This is a C#, server-side method. Under the 'new Dictionary' item list, we added the missing item by its item type name and the name in which we would like to describe it--there should be others listed as well to model from. Your switch(thisType) list should be consistent with the new Dictionary list below it as well. After saving this method, your item should be able to save and float that information. If it does not, inspect other dictionary code lines in your float methods.0Views1like0Comments