web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)

(0) ShareShare
ReportReport
Posted on by

I have two fields avd_starttime and avd_stoptime. I am writing the below code to update the avd_stoptime field with datetime.now. But I am getting the error as "Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)."..PLease tell me where I am going wrong??

 internal static bool StopAht(ICrmContext context)
        {
            QueryExpression exp = new QueryExpression(avd_agenthandlingtime.EntityLogicalName);
            exp.NoLock = true;
            exp.ColumnSet.AddColumn(XrmAttributes.AgentHandlingTime.Id);
            exp.ColumnSet.AddColumn(XrmAttributes.AgentHandlingTime.StopTime);

            ConditionExpression CondOppId = new ConditionExpression();
            CondOppId.AttributeName = "avd_StopTime";
            CondOppId.Operator = ConditionOperator.Null;


           

            string timerId = XrmAttributes.AgentHandlingTime.Id;

            var coll = context.OrganizationService.RetrieveMultiple(exp);
            if (coll != null && coll.Entities != null && coll.Entities.Count > 0)
            {
                foreach (var ent in coll.Entities)
                {
                    avd_agenthandlingtime stopTimer = new avd_agenthandlingtime()
                    {
                        Id = new Guid(timerId),
                        avd_StopTime = DateTime.Now
                    };
                    context.AdminUpdate(stopTimer);


                }
            }
            return true;
        }

*This post is locked for comments

I have the same question (0)
  • ScottDurow Profile Picture
    21 on at
    RE: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)

    It looks like the value for timerId doesn't contain a valid GUID - what is the value of  XrmAttributes.AgentHandlingTime.Id

  • Suggested answer
    Yadnyesh Kuvalekar Profile Picture
    4,102 on at
    RE: Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)

    Hi,

    XrmAttributes.AgentHandlingTime.Id


     As per above statement in your code, XrmAttributes.AgentHandlingTime.Id seems to have logical name of the field.

    string timerId = XrmAttributes.AgentHandlingTime.Id;


     In above line, you are setting the logical name of the field to timerId and in your loop, you are trying to convert it to GUID. How logical name can be converted into the GUID?

    Instead, try using below code:

    Id = ((Entity)ent).GetAttributeValue<Guid>(timerId),

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.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

#3
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans