Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

crm dynamics 2016 online : how to save the initial value of a field

Posted on by Microsoft Employee

Hello all,

May be it's very easy to do!

I have a date field named validity_date that can be updated many time. I want to keep the initial value in a new field called initial_validity_date. This later must be unchanged. What is the best approch to do that?

Thanks a lot

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: crm dynamics 2016 online : how to save the initial value of a field

    thanks Radu for your advising. that help me to find solution within business rule as suggested by Goutam

    Regards

  • Verified answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: crm dynamics 2016 online : how to save the initial value of a field

    Hello,

    Use business rules, the main advantages to use is that it will set form load  at the time of html DOM load.

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: crm dynamics 2016 online : how to save the initial value of a field

    Hello,

    I think you can use business rules.

  • Verified answer
    Radu Chiribelea Profile Picture
    Radu Chiribelea 6,667 on at
    RE: crm dynamics 2016 online : how to save the initial value of a field

    Hi bardouni,

    You could consider following approach:

    1. Add both fields to the form and make the initial_validity_date read only (disabled) so that it can't be changed manually

    2. add an OnChange event for the validity_date. That method should check if the initial_validity_date is null - and if so, then copy the value from the validity_date to the initial_validity_date.

    3. Also , you will have to set the submitmode to always for the initial_validity_date - so that this gets submitted to the CRM Platform.

    With the above logic, it will only copy the validity_date to the initial validity date if this never contained any data.

    The could could look something like:

    function InitializeValidityDate()
    {
        var pageObj = Xrm.Page;
        var initial_validity_date = pageObj.getAttribute("initial_validity_date");
        var validity_date_value = pageObj.getAttribute("validity_date").getValue();
    
        if(initial_validity_date.getValue() == null)
        {
            initial_validity_date.setValue(validity_date_value);
            initial_validity_date.setSubmitMode("always");
        }
    }


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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans