locked
how to conver guid id to this format RRS feed

  • Question

  •  i created guid id but i given reference to the entity reference it should be e359608e-8657-e511-80d8-3863bb2e4468 how to convert this format

    Friday, September 11, 2015 6:46 AM

Answers

  • Your issue is obvious. {id} is not correct format for Guid. Correct format is something like {e5e10562-6c25-4133-b015-29c8e4679255}. That's why you get run time error.

    Now I have next question - where do you want to get id of contact from to use it during creation of case?


    Dynamics CRM MVP
    My blog

    Friday, September 11, 2015 8:44 AM
    Moderator

All replies

  • Hello,

    I'm really sorry but I don't understand your question.


    Dynamics CRM MVP
    My blog

    Friday, September 11, 2015 6:55 AM
    Moderator
  • when i am trying to create case  contactid  it should be{xxxxxx-xxxx-xxxx-xxxx_xxxxxxxx}

    please reply me i need this answer

    Friday, September 11, 2015 7:28 AM
  • I'm sorry but it is still not clear. What exact issue do you have with samples, code, screenshots, error logs if available - everything that can make clear what do you mean.

    Dynamics CRM MVP
    My blog

    Friday, September 11, 2015 7:45 AM
    Moderator
  • i get guid id in the format   contact id= {xxxx_xxxxx} at runtime when i given this guid id inthe form of contactid  it  not taken


    An exception of type 'System.ServiceModel.FaultException`1' occurred in Microsoft.Xrm.Sdk.dll but was not handled in user code

    Guid id = entities.Id;
                            Entity incident = new Entity("incident");
                            incident["title"] = "Case subject";

                            // Set customerid with some existing contact guid 
                            Guid customerid = new Guid("{id}");

                            // Set customerid as contact to field "customerid" 
                            EntityReference CustomerId = new EntityReference("contact", customerid);
                            incident["customerid"] = CustomerId;

                            // Set contactid with some existing contact guid 
                            Guid contactid = new Guid("{id}");

                            // Set contactid as contact to field "casecontactid" 
                            EntityReference primaryContactId = new EntityReference("contact", contactid);
                            incident["casecontactid"] = primaryContactId;

                            _orgService.Create(incident);

    Friday, September 11, 2015 7:54 AM
  • Hello,

    1. Please stop create different topic with the same issues. That could not help you with solution.

    2. Your issue is still not clear. Please describe it in detail.


    Dynamics CRM MVP
    My blog

    Friday, September 11, 2015 8:13 AM
    Moderator
  • An exception of type 'System.FormatException' occurred in mscorlib.dll but was not handled in user code

    Additional information: Expected hex 0x in '{0}'.

    Guid customerid = new Guid("{id}");

     Guid id = entities.Id;
                            Entity incident = new Entity("incident");
                            incident["title"] = "Case subject";

                            // Set customerid with some existing contact guid 
                            Guid customerid = new Guid("{id}");

                            // Set customerid as contact to field "customerid" 
                            EntityReference CustomerId = new EntityReference("contact", customerid);
                            incident["customerid"] = CustomerId;

                            // Set contactid with some existing contact guid 
                            Guid contactid = new Guid("{id}");

                            // Set contactid as contact to field "casecontactid" 
                            EntityReference primaryContactId = new EntityReference("contact", contactid);
                            incident["casecontactid"] = primaryContactId;

                            _orgService.Create(incident);

    Friday, September 11, 2015 8:31 AM
  • I strongly suggest to take first a C# development course and after a Dynamics CRM development course.

    There are several free courses available on internet, including youtube and Microsoft Virtual Academy

    https://www.microsoftvirtualacademy.com/


    My blog: www.crmanswers.net - CRM Theme Generator

    Friday, September 11, 2015 8:41 AM
  • Your issue is obvious. {id} is not correct format for Guid. Correct format is something like {e5e10562-6c25-4133-b015-29c8e4679255}. That's why you get run time error.

    Now I have next question - where do you want to get id of contact from to use it during creation of case?


    Dynamics CRM MVP
    My blog

    Friday, September 11, 2015 8:44 AM
    Moderator
  •                       

     string  abc = Session["ab"].ToString();
                     QueryExpression qe = new QueryExpression("contact");
                     qe.ColumnSet.AllColumns = true;
                     qe.Criteria.AddCondition("fullname", ConditionOperator.NotEqual, "xxxxx");
                     qe.Criteria.AddCondition("new_username", ConditionOperator.Equal, abc);
                     EntityCollection collection = _orgService.RetrieveMultiple(qe);
                    foreach (Entity entities in collection.Entities)
                    {
                        string d=entities["new_username"].ToString();
                        if (abc==d)
                        {

                            Guid id = entities.Id;

                            Entity incident = new Entity("incident");
                            incident["title"] = "Case subject";

                            // Set customerid with some existing contact guid 
                            Guid customerid = new Guid("{id}");
                            // Set customerid as contact to field "customerid" 
                            EntityReference CustomerId = new EntityReference("contact", customerid);
                            incident["customerid"] = CustomerId;

                            // Set contactid with some existing contact guid 
                            //Guid contactid = new Guid("{id}");


                            // Set contactid as contact to field "casecontactid" 
                            EntityReference primaryContactId = new EntityReference("contact",id);
                            incident[" primaryContactId"] = primaryContactId;

                            _orgService.Create(incident);

    please check this code



    Friday, September 11, 2015 9:06 AM
  • {e5e10562-6c25-4133-b015-29c8e4679255} how to write this format i didn't under stand

    please give me some example code

    Friday, September 11, 2015 9:08 AM
  • i want to get account entity but i take contact entiy sory  but how to creaate guid {XXXXXXXXXXXXXXXXX} format

    Friday, September 11, 2015 9:31 AM
  • You need to get this ID from CRM, which will represent some account or contact, First go to CRM application and open any CRM account or contact record, press F11 so that you will be able to see address bar and then from there copy Id, so it like be something like this id="id=%7b15462A54-1620-42B5-A100-55FAA4A594A0%7d" just copy id after %7b and before %7d then use that id in your code.


    Mahender 


    Friday, September 11, 2015 9:40 AM
    Moderator
  •    using (_orgService = new OrganizationService(Class1.GetCRMService()))
                {
                   
                     QueryExpression qe = new QueryExpression("account");
                     qe.ColumnSet.AllColumns = true;
                     qe.Criteria.AddCondition("name", ConditionOperator.NotEqual, "xxxxx");
                     qe.Criteria.AddCondition("new_username", ConditionOperator.Equal, abc);
                     EntityCollection collection = _orgService.RetrieveMultiple(qe);
                    foreach (Entity entities in collection.Entities)
                    {
                        string d=entities["new_username"].ToString();
                        if (abc==d)
                        {

                            Guid id = entities.Id;

                            Entity incident = new Entity("incident");
                            incident["title"] = "Case subject";

                            // Set customerid with some existing contact guid 
                            Guid customerid = new Guid("{id}");
                            // Set customerid as contact to field "customerid" 
                            EntityReference CustomerId = new EntityReference("contact", customerid);
                            incident["customerid"] = CustomerId;

                            // Set contactid with some existing contact guid 
                            //Guid contactid = new Guid("{id}");
                          

                            // Set contactid as contact to field "casecontactid" 
                            EntityReference primaryContactId = new EntityReference("contact",id);
                            incident[" primaryContactId"] = primaryContactId;

                            _orgService.Create(incident);
                        }

                    }


                  



                        }
    Friday, September 11, 2015 9:42 AM
  • can you please STOP to open new threads with the same problem?

    My blog: www.crmanswers.net - CRM Theme Generator

    Friday, September 11, 2015 9:47 AM
  • please help me i didn't get answer
    Friday, September 11, 2015 10:33 AM
  • Friday, September 11, 2015 12:02 PM
  •  using (_orgService = new OrganizationService(Class1.GetCRMService()))
                {
                   
                     QueryExpression qe = new QueryExpression("contact");
                     qe.ColumnSet.AllColumns = true;
                     qe.Criteria.AddCondition("fullname", ConditionOperator.NotEqual, "xxxxx");
                     qe.Criteria.AddCondition("new_username", ConditionOperator.Equal, abc);
                     EntityCollection collection = _orgService.RetrieveMultiple(qe);
                    foreach (Entity entities in collection.Entities)
                    {
                        string d=entities["new_username"].ToString();
                        if (abc==d)
                        {

                           
                            Guid id = entities.Id;
                            Entity incident = new Entity("incident");
                            incident["title"] = "Case subject";

                            // Set customerid with some existing contact guid 
                            Guid customerid = new Guid("{id}");

                            // Set customerid as contact to field "customerid" 
                            EntityReference CustomerId = new EntityReference("contact", customerid);
                            incident["customerid"] = CustomerId;

                            // Set contactid with some existing contact guid 
                            Guid contactid = new Guid("{id}");

                            // Set contactid as contact to field "casecontactid" 
                            EntityReference primaryContactId = new EntityReference("contact", contactid);
                            incident["casecontactid"] = primaryContactId;

                            _orgService.Create(incident);
                        }

                    }
    Friday, September 11, 2015 12:03 PM
  • i retrive id from contact entity   i have two fields user name  and password in that entity 

    please answer me  this is verry usefull forme

    Friday, September 11, 2015 12:04 PM