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 :
Customer experience | Sales, Customer Insights,...
Suggested Answer

change the activity status

(0) ShareShare
ReportReport
Posted on by 5,514
 change the activity- status to completed
 
 
 
 
Categories:
I have the same question (0)
  • Suggested answer
    Saif Ali Sabri Profile Picture
    2,351 Super User 2025 Season 2 on at

    To change the activity status to Completed after clicking Save & Close, you can use JavaScript with a synchronous call to update the status before the form closes.
    Here’s a concise solution:

    Steps:

    1. Add JavaScript Web Resource to the activity form.
    2. Register the script on the OnSave event (not OnClose).

    JavaScript Code:

    javascript

    function setActivityStatusOnSave(executionContext) {
    var eventArgs = executionContext.getEventArgs();

    // Check if Save & Close (save mode 70)
    if (eventArgs.getSaveMode() === 70) {
    var formContext = executionContext.getFormContext();

    // Set Status Reason to 'Completed' (value depends on entity)
    formContext.getAttribute("statuscode").setValue(Completed_Status_Code); // e.g., 2 for Email

    // Set State to 'Completed' (1)
    formContext.getAttribute("statecode").setValue(1);
    }
    }

    Replace Completed_Status_Code with the actual value for “Completed” in your activity (e.g., for Email it's 2).

    Register Script:

    • Event: OnSave
    • Function: setActivityStatusOnSave
    • Scope: Form
    • Check “Pass execution context”

    This ensures the status is updated before the form is closed.

  • Anne Stanton, MCSE, MBA, CRM rMVP #7 Profile Picture
    65 on at
    Users can use the "Completed" checkmark from history to quickly close an activity as completed.
     
    What is the use case that this requires custom code that the customer would have to manage long term? There are also needs to keep activities open. This one needs more discussion.
     
    cheers Anne
  • sandeepc Profile Picture
    5,514 on at
    .
  • sandeepc Profile Picture
    5,514 on at
    .

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 > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 170 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 61

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 52 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans