Notifications
Announcements
No record found.
Hi all,
I am trying to add guids to an array of type guid in CRM 2016 On premise version
How can i do this any sample links/code please
Thanks in advance
Naren
Hi,
Where do you do that? in jscript?
Is that a field like regarding, to, cc?
Regards,
Hello,
Refer to this sample C# code:
Guid id1 = new Guid("2d67aef2-3a29-4497-b4fc-b5d0c450ed48"); Guid id2 = new Guid("d73368f1-6e6a-4c9e-933e-a658eb55b2c9"); // Dynamic array of Guid type Guid[] guidArray = new Guid[] {id1, id2}; foreach(var id in guidArray) { Console.WriteLine("id : " id); } Console.WriteLine("\n"); // Dynamic array of a collection List idsCollection = new List(); idsCollection.Add(id1); idsCollection.Add(id2); foreach(var id in idsCollection){ Console.WriteLine("id: " id); } Console.ReadLine();
Mehdi,
Hi thanks for your reply
I want in C# method
I am passing array of string which will have guids with comma separated list.
I need to validate each item whether it is a guid or not and return array of guids of type guid array.
Public static guid[] isGuidArray(...)
Please check the code above. thank you.
You can use Guid.Parse and Guid.TryParse for that.
docs.microsoft.com/.../system.guid.parse
docs.microsoft.com/.../system.guid.tryparse
static void Main(string[] args) { String[] guidsToValidate = new string[] { "2d67aef2-3a29-4497-b4fc-b5d0c450ed48", "falseId", "d73368f1-6e6a-4c9e-933e-a658eb55b2c9" }; Guid guidToAdd; List guidCollection = new List(); foreach (var guidTovalidate in guidsToValidate) { if(TryParseGuid(guidTovalidate, out guidToAdd)) { guidCollection.Add(guidToAdd); } } foreach(var id in guidCollection) { Console.WriteLine("valid id: " id); } Console.ReadLine(); } //code found on stackoverflow public static bool TryParseGuid(string guidString, out Guid guid) { if (guidString == null) throw new ArgumentNullException("guidString"); try { guid = new Guid(guidString); return true; } catch (FormatException) { guid = default(Guid); return false; } }
Check this code.
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Tom_Gioielli 108 Super User 2025 Season 2
Jimmy Passeti 50 Most Valuable Professional
Gerardo RenterÃa Ga... 49 Most Valuable Professional