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 :
Microsoft Dynamics CRM (Archived)

How to update statuscode and statecode of a record in 'Activities' Entity?

(1) ShareShare
ReportReport
Posted on by 5

Hi Guys,

I have created a grid(web resource) and added on Contact form. This grid holds all active activities for that particular contact. There is a button (Mark complete) in the grid.

So when user click on 'Mark complete' button, PhoneCall activity should be marked completed.

Version:  MS Dynamics 8.2.

Please suggest me how to set status/state code of that activity using JavaScript/c#

Regards,

Rohit

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Dynamics365 Rocker Profile Picture
    7,755 on at
    RE: How to update statuscode and statecode of a record in 'Activities' Entity?

    If your grid has multiple activities then get Activity name from selected record and update State and Status code of that particular activity like email, phone call etc.

    You also need to pass activity id to email or phonecall while updating.

  • Suggested answer
    Pawar Pravin  Profile Picture
    5,237 on at
    RE: How to update statuscode and statecode of a record in 'Activities' Entity?

    Hi Rohit,

    Instead of Activity Pointer please try Phone call entity directly.

    var entity = {};
    entity.statecode = 1;
    entity.statuscode = 4;

    var req = new XMLHttpRequest();
    req.open("PATCH", Xrm.Page.context.getClientUrl() + "/api/data/v9.0/phonecalls(2736F79A-7C45-E911-A816-000D3A0B39D8)", true); // Replace GUID with your phone call activity record
    req.setRequestHeader("OData-MaxVersion", "4.0");
    req.setRequestHeader("OData-Version", "4.0");
    req.setRequestHeader("Accept", "application/json");
    req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
    req.onreadystatechange = function() {
    if (this.readyState === 4) {
    req.onreadystatechange = null;
    if (this.status === 204) {
    //Success - No Return Data - Do Something
    } else {
    Xrm.Utility.alertDialog(this.statusText);
    }
    }
    };
    req.send(JSON.stringify(entity));

  • Rohit Dixit Profile Picture
    5 on at
    RE: How to update statuscode and statecode of a record in 'Activities' Entity?

    Hi Kokulan,

    Thanks for your response !

    I was trying to update the "StatusCode" and "StateCode" in 'ActivityPointer' entity based on the 'ActivityId'.

    But while creating a patch request, error comes. It stated that 'ActivityPointer' entity does not support the update request.

    For other entities like Accounts/Incidents, Option Set value updated through patch request.

    Kindly Suggest how should I 'Mark Complete' the activities(Phone Call/ Email) available in webresource GRID.

    Thanks !

  • Suggested answer
    Kokulan Profile Picture
    18,054 on at
    RE: How to update statuscode and statecode of a record in 'Activities' Entity?

    Hi

    Please refer to the example in the link below

    community.dynamics.com/.../254051

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 > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Aric Levin - MVP Profile Picture

Aric Levin - MVP 2 Moderator

#2
MA-04060624-0 Profile Picture

MA-04060624-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans