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
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.
Mehdi,
Hi,
You can use Guid.Parse and Guid.TryParse for that.
docs.microsoft.com/.../system.guid.parse
docs.microsoft.com/.../system.guid.tryparse
Regards,
Hello,
Please check the code above. thank you.
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(...)
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,
Where do you do that? in jscript?
Is that a field like regarding, to, cc?
Regards,
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156