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

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Update task record after "mark as complete" on update message

(0) ShareShare
ReportReport
Posted on by 458

I need to update some fields and do some login on task entity. Actually based on my requirement, when the task record status change to complete(user click on Mark as Complete.), my logic must start. For this reason and because of no event like complete in task messages, I check status of the record in update message. I would like to this via CRM Plugin. To achieve this I use PostEntityImages of task record. I check the status of PostEntityImages in the code and then do my logic. This is what happening :

 if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
        {
            currentTask = (Entity)context.InputParameters["Target"];
            if (currentTask.LogicalName == "task")
            {
                afterUpdateTask = (Entity)context.PostEntityImages["updatedTask"];
                beforeUpdateTask = (Entity)context.PreEntityImages["updatedTask"];
                if (afterUpdateTask.Contains("statuscode"))
                {
                    int statuscode = ((OptionSetValue)afterUpdateTask["statuscode"]).Value;

                    if (statuscode == 5)
                    {

As you see I also get the PreEntityImages as well. After last if, the logic starts and some fields update; the fields of PostEntityImages(afterUpdateTask ). But CRM returns : 

The object cannot be updated because it is read-only. If you contact support, please provide the technical details.

It seems CRM does not talk much off ! I also tried this with PreEntityImages(beforeUpdateTask), but it does not work for me. Because it updates the fields in task entity, but does not change the status of record to complete, however in my scenario I need the modifiedon and statuscode fields of PostEntityImages. Also tried with currentTask that is (Entity)context.InputParameters["Target", but it just change the stauts of record to complete without running my logic.

What should I do to update a task record after it change to complete? Is it possible to do this via Plugin?

I have the same question (0)
  • Albert_ Profile Picture
    458 on at
    RE: Update task record after "mark as complete" on update message

    Actually I use Pro-Operation.

    Also I made an image of the task ( post and pre ) and use that image to update.

    Thanks a lot.

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Update task record after "mark as complete" on update message

    Hello,

    First of all - what version of CRM do you use? I might be wrong but a few versions back Microsoft removed the restriction to update inactive records.

    You can try the following:

    1. Use a "pre-plugin".

    2. Get statuscode from the "Target".

    3. Add fields to be updated to "Target".

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Daniyal Khaleel Profile Picture

Daniyal Khaleel 147

#2
DAnny3211 Profile Picture

DAnny3211 134

#3
Abhilash Warrier Profile Picture

Abhilash Warrier 70 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans