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)

Can not assign task to a team entity

(0) ShareShare
ReportReport
Posted on by 410

Hi Guys, I am creating a plugin, where i just need to assign a task to a team, the plugin tiggers an error and it is registered in the post event and a Create message name to a custom entity. I have debugged it and it gives this error - "error in assigning task : System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: Creating Entity with an invalid parent. Entity: Task, ReferencingAttribute:regardingobjectid (Fault Detail is equal to Microsoft.Xrm.Sdk.OrganizationServiceFault)."

Anyone knows why?

My code is below:

if(context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
            {
                Entity travelDetail = (Entity)context.InputParameters["Target"];

                if(travelDetail.LogicalName != "gg_traveldetail") { return; }

                try
                {
                    QueryByAttribute teamQuery = new QueryByAttribute("team");
                    teamQuery.AddAttributeValue("name", "Travel Consultants");

                    EntityCollection retrievedTeam = service.RetrieveMultiple(teamQuery);

                    Entity travelConsultantTeam = (Entity)retrievedTeam.Entities[0];

                    Guid travelconId = travelConsultantTeam.Id;


                    Entity task = new Entity("task");

                    task.Attributes["subject"] = "New Travel Booking Created";
                    task.Attributes["ownerid"] = new EntityReference(travelConsultantTeam.LogicalName, travelconId);
                    task.Attributes["description"] = "A new travel booking has been created for a staffing role.";

                    if (context.OutputParameters.Contains("id"))
                    {
                        Guid regardingobjectid = new Guid(context.OutputParameters["id"].ToString());
                        string regardingobjectidType = "gg_traveldetail";

                        task.Attributes["regardingobjectid"] =
                        new EntityReference(regardingobjectidType, regardingobjectid);
                    }

                    service.Create(task);

Thanks for the help guys.

*This post is locked for comments

I have the same question (0)
  • Victor Onyebuchi Profile Picture
    410 on at

    the error is at service.create(task). The follwing error -  System.Runtime.Remoting.RemotingException: 'Object '/fdea2c23_b782_48a9_b73a_188a4190e1a0/kosugxghcrrlfi9mvc0a5tg1_75.rem' has been disconnected or does not exist at the server.'

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

    Hi Victor,

    The first error in yoru question is related to the missing permission for the team security role. Assign the read permission for the activity entity on the role assigned to the team.

    Hope this helps.

  • Victor Onyebuchi Profile Picture
    410 on at

    I have given the team a system administrator role.

  • Suggested answer
    oliver.rodrigues Profile Picture
    4,052 on at

    You will get this message if there is no Security Role assigned to your Team

    Make sure you go to your team and assign a valid Role with permissions to Activities

  • Victor Onyebuchi Profile Picture
    410 on at

    The role issue has been resolved, but it is throwing an error still -   "error in assigning task : System.ServiceModel.FaultException`1[Microsoft.Xrm.Sdk.OrganizationServiceFault]: Creating Entity with an invalid parent. Entity: Task, ReferencingAttribute:regardingobjectid (Fault Detail is equal to Microsoft.Xrm.Sdk.OrganizationServiceFault)."

    Anyone knows why?

  • Suggested answer
    oliver.rodrigues Profile Picture
    4,052 on at

    are you sure it is retrieving the GUID correctly  ?

    and another question.. this plugin seems to be basically getting an specific team, and assigning to it

    if it is a static team, why not use a Workflow to create the task ?

    just make sure to migrate your teams between your environments with the same GUID (you can use configuration migration tool for that, from SDK)

  • Victor Onyebuchi Profile Picture
    410 on at

    I am sure it is getting a valid Guid and I am only doing as told by my boss (to use plugin and not workflow). I have never used configuration migration tool before as well. Why shouldnt this plugin work tho?? seems to be correct, other prople have had similar problem, but it is regarding sending emails and not task.

  • Suggested answer
    oliver.rodrigues Profile Picture
    4,052 on at

    The plugin code seems fine, it should work, it is registered on the post-operation right ?

    Although I would try to understand with your boss why not go for a Workflow which seems to be easier

  • Victor Onyebuchi Profile Picture
    410 on at

    Yes, registered on post event. We support the production CRM remoyely, plugin seems convenient to always manage.

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

    Hi Victor,

    It seems you have updated the error message in your question. Previously it was related to permission but now it different. The troubleshooting, resolution, fix depends upon the error message an if you change the error message (without mentioning it)  then it would be difficult to troubleshoot as we won't know what all steps have you already done and whats the current error message.

    Anyways, this error "Creating Entity with an invalid parent." occurs if you have not enabled activities for the parent entity i.e. in your case, the custom entity which you are setting up as regarding for this tak. Navigate to Setting >> Customizations >> Customize the solution >> Entities >> {Click on your custom entity} >> within the properties, select "Activites" followed by save and publish.

    This should fix the error you are currently getting i.e. "Creating Entity with an invalid parent."

    Hope this helps.

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