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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to programmatically assign 'SYSTEM' to the owner of a record through organizationservice?

(0) ShareShare
ReportReport
Posted on by

Hi,

We are developing an external portal as we did not succeed with the custom portal provided with CRM. We would like to show the contact creating the record on the portal as the owner of the record. I read that is not supported as that is not a paying user. The portal was able to create records with SYSTEM. How can we do the same to indicate the records have been created externally?

J.

//try to change owner;
var request = new AssignRequest
{
Assignee = new EntityReference(SystemUser.EntityLogicalName, Guid.Parse("?")),
Target = new EntityReference(MyClaim.EntityLogicalName, NewClaim.Id)
};
// Execute the Request
_serviceContext.Execute(request);

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    SCV Profile Picture
    1,004 on at

    Try this

    // Create the Request Object and Set the Request Object's Properties
    
               AssignRequest assign = new AssignRequest
    
               {
    
                   Assignee = new EntityReference(SystemUser.EntityLogicalName, new Guid("Guid of the system account")),
    
                   Target = new EntityReference("entity logical name", new Guid("Guid of the user"))
    
               };
    
               // Execute the Request
    
               orgService.Execute(assign);
    
  • Community Member Profile Picture
    on at

    Thank you. How to get the system account guid? Where to find it?

  • Suggested answer
    SCV Profile Picture
    1,004 on at

    You can open the user record in CRM and in the ribbon click "Email a link button". Then it will create a draft email with the link. Similar to this.

    1&extraqs=formid%3de276a667-23fc-4fe0-affb-56bc1952d6cb&id=%7bA120C89F-1DB6-E311-8C72-005056B46274%7d&pagetype=entityrecord>

     

    There you get the guid after 7b part ( I have bolded it).

    Please note this id might change from dev to uat. So you can keep this in one of your config files.

  • Community Member Profile Picture
    on at

    Thank you. I new this. But for some reason the system user does not show up. How did the portal do this?

  • Suggested answer
    SCV Profile Picture
    1,004 on at

    In CRM go to security->users and search for "CRM Service" and you should get the user account. Open and click the "Email a link" button. Then get the GUID.

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi,

    You can do an advanced find to list all users. Once you get the System user in the results, open the record and from the browser URL you can get the system guid (take the values between '%257b' & '%257d').

    testjulycrm.crm6.dynamics.com/main.aspx;extraqs=%3f_gridType%3d8%26etc%3d8%26id%3d%257b971F403D-D63C-4B72-8586-DE49BC036524%257d%26rskey%3d%257b00000000-0000-0000-00AA-000000666D00%257d&histKey=760813914&newWindow=true&pagetype=entityrecord&rskey=%7b00000000-0000-0000-00AA-000000666D00%7d#715905832

    systemguid.png

    However, I don't think you can use assign request to assign the record to system user as it is an internal account.

    Some good read about this here-

    community.dynamics.com/.../explaining-the-built-in-system-and-integration-users

    You can however achieve this from plugin or workflow by not passing the user id while creating the

    var service = serviceFactory.CreateOrganizationService(null);

  • Community Member Profile Picture
    on at

    Thank you. How to do this with dependency injection (not a CRM plugin)?

                var crmConnection = CrmConnection.Parse(System.Configuration.ConfigurationManager.ConnectionStrings["OnPremiseIFD"].ConnectionString);                       
    
                var organizationService = new OrganizationService(crmConnection);
    
                For<IOrganizationService>()
                    .Use<OrganizationService>()
                    .Ctor<CrmConnection>()
                    .Is(crmConnection);
    
                For<Dynamics.Crm.Service.IServiceContext>()
                    .Use<Dynamics.Crm.Service.ServiceContext>()
                    .Ctor<IOrganizationService>()
                    .Is(organizationService);


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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans