Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Update on latest date

Posted on by 40

Hi There,

I have created an entity where there is an attributes for expected date of closure. In this entity, there is a sub-grid where there are 3 attributes for "expected date of closure". What i want is that main page "expected date of closure" gets updated with latest date available in sub-grid 3 attributes of "expected date of closure". Please help if it is possible.

Thanks in advance

Hanshu

*This post is locked for comments

  • Miasm1 Profile Picture
    Miasm1 2 on at
    Update on latest date
    Hi Hanshu,
    it is possible to achieve what you're looking for. You can use JavaScript to fetch the values of the "expected date of closure" from the sub-grid attributes and then update the main page attribute with the latest date. You'll need to add a script on the form that contains this entity.
    Here's a high-level example using JavaScript and assuming you're working with a CRM-like system:
     
    // Assuming 'Xrm' is the CRM client object model
    var subgridControl = Xrm.Page.getControl("your_subgrid_name");
    
    if (subgridControl != null) {
        var rows = subgridControl.getGrid().getRows();
    
        // Initialize with a date in the past
        var latestDate = new Date(1900, 0, 1);
    
        // Iterate through subgrid rows to find the latest date
        rows.forEach(function (row, index) {
            var dateValue1 = row.getData().getEntity().getAttributes().get("new_date_attribute_1").getValue();
            var dateValue2 = row.getData().getEntity().getAttributes().get("new_date_attribute_2").getValue();
            var dateValue3 = row.getData().getEntity().getAttributes().get("new_date_attribute_3").getValue();
    
            // Update latestDate if a newer date is found
            if (dateValue1 != null && dateValue1 > latestDate) {
                latestDate = dateValue1;
            }
            if (dateValue2 != null && dateValue2 > latestDate) {
                latestDate = dateValue2;
            }
            if (dateValue3 != null && dateValue3 > latestDate) {
                latestDate = dateValue3;
            }
        });
    
        // Update the main page attribute with the latest date
        Xrm.Page.getAttribute("new_expected_date_of_closure").setValue(latestDate);
    }
    
    "new_date_attribute_2," "new_date_attribute_3," and "new_expected_date_of_closure" with your actual sub-grid name and attribute names.
    This script assumes you are using the CRM client object model. Adjustments may be needed based on the specific platform or framework you are working with.
     
     
    I hope this will help you.
  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Update on latest date

    To be honest, even if I have long deadlines I always write my essays at the last moment, I can't put myself to write them peacefully with some days prior. This is why I am always using editing services as due to lack of time I can't concentrate on writing them without mistakes. However, I pay attention to the college essay editing cost because as a student I can't afford every service, but there are many who offer qualitative services at a reasonable price.

  • Suggested answer
    Piyush Paliwal Profile Picture
    Piyush Paliwal 817 on at
    RE: Update on latest date

    This is very much possible. Follow these simple steps to get it done. The trigger point of this logic would play an important role in deciding the overall performance of the solution.

    • Write a plug-in on post creation or post update of the record in sub-grid
    • In your plug-in code, retrieve all the child entity records which are associated with that particular parent entity.
    • Once you have this data just identify the latest date from all of the records. There are multiple ways of doing it but am sure you are a .net developer and would be able to figure out how this identification has to be done.
    • After identifying the date, just update the parent record with this date and you are done.

    Let me know if 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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,900 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,275 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans