Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

How to capture modifiedon field from the form using javascript and populate custom field

Posted on by 340

i want to capture modifiedon field using javascript and update the value to the custom field how can this be achieved, every time modifiedon updated custom field should be updated

*This post is locked for comments

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to capture modifiedon field from the form using javascript and populate custom field

    [quote user="Sandy Hello"]

    Hi Guido this is the business requirement to calculate difference between start date and end date.Thanks for reply

    [/quote]

    Hi,

    Have you tried using calculated fields?

    Create a Calculated field of type whole number. 

    1401.Capture1.PNG

    1401.Capture1.PNG

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to capture modifiedon field from the form using javascript and populate custom field

    Use this code on save event of the form.

    function setModifiedOn(){
    var ismodified = Xrm.Page.data.entity.getIsDirty();
    if(ismodified){
    	
    	var currentDateTime = new Date();
    	Xrm.Page.getAttribute("new_date1").setValue(currentDateTime);
    
    }
    }



  • Sandy Hello Profile Picture
    Sandy Hello 340 on at
    RE: How to capture modifiedon field from the form using javascript and populate custom field

    Hi Guido this is the business requirement to calculate difference between start date and end date.Thanks for reply

  • Suggested answer
    Rajkumar Rajaraman Profile Picture
    Rajkumar Rajaraman 18,108 on at
    RE: How to capture modifiedon field from the form using javascript and populate custom field

    Refer this:

    community.dynamics.com/.../152734

  • Piotr Kalwasinski Profile Picture
    Piotr Kalwasinski 240 on at
    RE: How to capture modifiedon field from the form using javascript and populate custom field

    Hi,

    I think you want to capture who has updated the custom field, where you suggest the logic of inspecting the modifiedon field. I would not recommend to use JS for this, as JS can only be run on the form. I believe the back-end solution (plugin/workflow) would be better.

    Depending on what you want to achieve, potentially system workflow which is triggered on the update of "modifiedon" field may be sufficient. If your logic requires you to check condition that may not be directly on the updated record, you may need to write a bespoke code to achieve it.

    I hope this helps.

    Piotr

  • Sandy Hello Profile Picture
    Sandy Hello 340 on at
    RE: How to capture modifiedon field from the form using javascript and populate custom field

    Hi JaiG thanks for reply i didn't find any possibility to make the above task to achieve through business rule. Please can you elaborate it.

  • Suggested answer
    JaiG Profile Picture
    JaiG on at
    RE: How to capture modifiedon field from the form using javascript and populate custom field

    You don't have to use JS to do this.

    You should be able to achieve this through a Workflow.

    Simply monitor the modifiedon field and have your workflow updaterecord with your field set to either current time or equal to modified on time.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans