Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Dynamics 365-Assigning Resource to a task

Posted on by Microsoft Employee

Hi,

I am trying to allocate resource to a task in Dynamics 365 programmatically. The code is:

private static void AssignResourceToTask(XrmServiceContext xrm)
        {
            Guid TaskId = new Guid("40e1f9d7-9e8d-4d18-8d0d-08e8ec6ccb4b");
            Guid ResourceId = new Guid("30cd5482-94d1-e611-80e7-c4346bacbf10");
            Guid ProjectId = new Guid("666609d2-9510-e711-ae87-002713bd9b28");
            var AssignResource = new msdyn_resourceassignment
            {
                msdyn_resourceassignmentId = Guid.NewGuid(),
                msdyn_bookableresourceid = new Microsoft.Xrm.Client.CrmEntityReference("bookableresource", ResourceId),
                msdyn_taskid = new Microsoft.Xrm.Client.CrmEntityReference("msdyn_projecttask", TaskId),
                msdyn_projectid = new Microsoft.Xrm.Client.CrmEntityReference("msdyn_project", ProjectId)

            };

            xrm.AddObject(AssignResource);
            xrm.SaveChanges();

        }

But I am unable to assign resource to a task using the above code.

*This post is locked for comments

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans