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)

Unable to Display value of a field after case is Resolved

(0) ShareShare
ReportReport
Posted on by 958

Hi All,

I made a custom fields named "Duration" and apply a script for the same which shows then time difference between "Created On" and "Resolved On" in Duration field when a case is resolved. This is done but, 

I am facing a strange issue that is ----->

When i am going to see the value of Duration field in the "View of Resolved Cases" then it shows the default value not the exact value. And if i am going to check the value of same resolved case record in the form then it shows the right value but not in views and reports.

Please suggest why this error is occurred and how could i resolve the same? 

*This post is locked for comments

I have the same question (0)
  • Alok Singh Profile Picture
    910 on at
    RE: Unable to Display value of a field after case is Resolved

    Hi Shakti,

    Please be informed that once case is resolved, the case record will be read only and can not edit anymore without reactivating the case. It is better to use Plugin.

  • FabioG Profile Picture
    130 on at
    RE: Unable to Display value of a field after case is Resolved

    have you tried Xrm.WebApi for update the record you need?

  • Shakti Singh Rajput Profile Picture
    958 on at
    RE: Unable to Display value of a field after case is Resolved

    I think we can not do this because as all suggested we can save a field value when a case record is resolved.

    But if anyone has better approach for the same then please let me know?

  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    33,626 on at
    RE: Unable to Display value of a field after case is Resolved

    Hi,

    your JavaScript only set the value, but didn't save it. Furthermore, you cant save the record after it is resolved.

    Use workflow or Plugin, or calculated field to achieve it.

    community.dynamics.com/.../difference-between-two-dates-with-calculated-fields

    http://www.crmconsultants.co.uk/calculate-duration-of-business-days-in-dynamics-365-crm/

    https://github.com/jlattimer/CRM-DateTime-Workflow-Utilities

  • FabioG Profile Picture
    130 on at
    RE: Unable to Display value of a field after case is Resolved

    I have an issue where i should update a field in resolve state. In that case i used an action to update the field, that run as administrator, cause the javascript can't update "close" record.

  • Shakti Singh Rajput Profile Picture
    958 on at
    RE: Unable to Display value of a field after case is Resolved

    Below is the code and apply this code OnLoad.

    And tell me one thing if we are resolved a case record then is there any save button appear?

    function Duration()

    {

    //alert("111");

    Xrm.Page.getAttribute("new_durationbtcreateandresolve").setValue(" ");

    var Code = Xrm.Page.getAttribute("statecode").getValue();

    if(Code==1)

    {

       var Start =window.parent.Xrm.Page.getAttribute("createdon").getValue();

       var endDate =window.parent.Xrm.Page.getAttribute("new_npuresolvedon").getValue();

       var Startdate = Start.getDay();

       var modifiedDay = endDate.getDay();

       var NoOfDay = Startdate-modifiedDay;

       var DayDiff ;

       var hoursFormate;

       var minformate;

       var diff = endDate - Start;

       var DayDiff = "0"+NoOfDay;

      if (NoOfDay < 10)

    {

     DayDiff = "0"+NoOfDay;}

      else

      {

           DayDiff = NoOfDay;

      }

       var hours   = Math.floor(diff / 3.6e6);

     if (hours < 10 )

     {

     hoursFormate =  "0"+hours;

     }

     else

    {

        hoursFormate = hours;

     }

       var minutes = Math.floor((diff % 3.6e6) / 6e4);

     if (minutes < 10)

    {

     minformate = "0"+minutes;}

     else

    {

      minformate = minutes;

     }

    var format =   DayDiff+":"+hoursFormate+":"+minformate;      

    Xrm.Page.getAttribute("new_durationbtcreateandresolve").setValue(format);

    }

    else

    {

     Xrm.Page.getAttribute("new_durationbtcreateandresolve").setValue("00 Days:00 Hours:00 Minutes");

    }

    }

  • FabioG Profile Picture
    130 on at
    RE: Unable to Display value of a field after case is Resolved

    So you have just an autopopulate field that isn't saved. With js you can calculate value to display, onload function, the data updated but this data aren't saved

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at
    RE: Unable to Display value of a field after case is Resolved

    Hi Shakti ,

    How do you set the the duration text field value in that case ? If you did in the  form onload then you have to save the records to show in the grid which means data need to  save in the DB .

  • Shakti Singh Rajput Profile Picture
    958 on at
    RE: Unable to Display value of a field after case is Resolved

    If a case record is resolved then there is no save functionality in that case record.

  • FabioG Profile Picture
    130 on at
    RE: Unable to Display value of a field after case is Resolved

    Did you save the record after the javascript has done his logic? maybe a formContext.data.save() with the submitemode("always") on the field should be the best solution and the one i think need to do. Probably you haven't saved your record, so when you left from the record the record didn't get saved

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…

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#2
Christoph Pock Profile Picture

Christoph Pock 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans