Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Update createdonbehalfby C#

Posted on by 420
Guid tId = context.Service.Create(new new_t()
{
new_name = name,
});
Entity t= new Entity("new_t", tId);
t.Attributes["createdonbehalfby"] = new EntityReference("systemuser", onBehalfBy.Id);
context.Service.Update(t);


I'm trying to update createdonbehalfby but it doesn't seem to work (code above), anyone know a way to do this?

*This post is locked for comments

  • Verified answer
    ARIFNIIT Profile Picture
    ARIFNIIT 1,391 on at
    RE: Update createdonbehalfby C#

    I think you can not change createdonbehalfby. it will be user id which will use for organization service authentication. you can change CreatedBy by using impersonation.

    using OrganizationServiceProxy.CallerId=userid

  • anonsgate Profile Picture
    anonsgate 420 on at
    RE: Update createdonbehalfby C#

    you cant write t.[, and doing new Guid is the same as OnBehalfBy.Id since it's of type Guid. The problem here is that createdonbehalfby is readonly and should only be written to by the system, but I'd like a way to avoid impersonification since in the context that I am, I don't have access to CallerID and ServerConnection.

  • Suggested answer
    Rawish Kumar Profile Picture
    Rawish Kumar 13,756 on at
    RE: Update createdonbehalfby C#

    have a look below as well : community.dynamics.com/.../190003

    mark my suggestion as verified if helpful.

  • Suggested answer
    Rawish Kumar Profile Picture
    Rawish Kumar 13,756 on at
    RE: Update createdonbehalfby C#

    try something like below and also post error if you are getting any?

    t.["lookupfield"] = new EntityReference("entityname", new Guid("baa25488-6d99-es11-99da-225056836fb7"));

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans