What is the correct way to parse DateTime on a server side onAfterGet event?
Hi everyone. I'm currently trying to evaluate the current date and a date property however, when I try do parse the string provided by getProperty, it gives me the error: String was not recognized as a valid DateTime. I can confirm the property is of the Type: Date and Pattern: Short Date. My relevant code: [embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:5ea4aa05-9cf8-4f39-aaab-d8f235e33c77:type=text&text=for%20%28int%20i%20%3D%200%3B%20i%20%3C%20this.getItemCount%28%29%3B%20i%2B%2B%29%0D%0A%7B%0D%0A%20%20%20%20Item%20thisItem%20%3D%20this.getItemByIndex%28i%29%3B%0D%0A%20%20%20%20%0D%0A%20%20%20%20string%20dateStr1%20%3D%20thisItem.getProperty%28%22_calibrated_next%22%2C%22%22%29%3B%0D%0A%20%20%20%20DateTime%20date1%20%3D%20DateTime.Parse%28dateStr1%29%3B%0D%0A%7D] The only thing that I can think of that may cause this error is the date format conversion when localized from neutral UTC, but I couldn't find much in the Aras documentation related to this. ThanksSolved4KViews0likes4CommentsCode 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. Daan0Views2likes0Comments