Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Getting error "UserId is empty guid" while updating userlookup

(0) ShareShare
ReportReport
Posted on by 111

Hi all,

I'm getting error when i try to set userlookup. Kindly help.

below is the code to update an user lookup field in quote entity.

if (userList.Entities.Count > 0)
{
EntityReference _user = new EntityReference(userList.Entities[0].LogicalName, userList.Entities[0].Id);
//this.user.Set(executioncontext, _user); new_levelapprovaluser
QueryExpression queryqd = new QueryExpression("quote");
queryqd.ColumnSet.AddColumns("new_levelapprovaluser");
queryqd.Criteria.AddCondition("quoteid", ConditionOperator.Equal, entity.Id);
EntityCollection qd = service.RetrieveMultiple(queryqd);
foreach (Entity allrecord1 in qd.Entities)
{
allrecord1["new_levelapprovaluser"] = new EntityReference(_user.LogicalName, _user.Id); ;
service.Update(allrecord1);
}
}

Thank you

*This post is locked for comments

  • Suggested answer
    Kokulan Profile Picture
    18,054 on at
    RE: Getting error "UserId is empty guid" while updating userlookup

    Hi

    If it throws an exception, could you check if there is any Inner Exception, and if there is one, please share message from that as well.

    It would be easier to spot errors if you could share the full code that does this update (Only share your code if possible).  

    Thanks

  • Amos Dave Profile Picture
    111 on at
    RE: Getting error "UserId is empty guid" while updating userlookup

    Hi Mansoor,

    Value exists.

  • Amos Dave Profile Picture
    111 on at
    RE: Getting error "UserId is empty guid" while updating userlookup

    Hi Kokulan,

    Thanks for you reply.

    I tried with your code. I'm getting the same error.  Once the control comes out of the service.update() it jumps to ecxception.

  • Suggested answer
    Mansoor Sulaiman Profile Picture
    4,330 on at
    RE: Getting error "UserId is empty guid" while updating userlookup

    Hi,

    Pls, check the value exists or not.

    Mansoor

  • Suggested answer
    Kokulan Profile Picture
    18,054 on at
    RE: Getting error "UserId is empty guid" while updating userlookup

    The following code should do what you are trying to do

       if (userList.Entities.Count > 0)

                   {

                       EntityReference _user = userList.Entities[0].ToEntityReference();

                       Entity quote = new Entity(entity.LogicalName, entity.Id);

                       quote["new_levelapprovaluser"] = _user;

                       service.Update(quote);

                   }

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 52

#3
dkrishna Profile Picture

dkrishna 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans