Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Populating the Effective Date

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello Everyone:

Can someone assist me in auto populating the Effective From and To dates on a quote. I would like that when I Create or save a Quote that it automatically puts in today's date for Effective from and then calculates 60 days to populate into the Effective To.

There was a post similar to this and they had this script and I placed it into the Quote form Properties but it did not work. Do I need to set some Parameters or use the Non-event Dependencies.

function SetDueDateField()
{
        var dateFieldValue= Xrm.Page.getAttribute('effectivefrom').getValue();
	var year = dateFieldValue.getFullYear();
	var month = dateFieldValue.getMonth();
	var day = dateFieldValue.getDate();
	var dateOnly = new Date(year,month,day)+60;
	Xrm.Page.getAttribute("effectiveto").setValue(dateOnly); 	
}

Any help would be great

Note I'm not a programmer


*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Populating the Effective Date

    Big thanks HIMBAP and Guido for the awesome help and info

  • Mahendar Pal Profile Picture
    Mahendar Pal 45,095 on at
    RE: Populating the Effective Date

    Hi,

    What issue you are getting ?? please make sure to use correct field name in your java script function for example, in below line you need to change effectivefrom with correct field name, usually it is prefix_fieldname, so if you are using default publisher then name should be "new_effectivefrom"

    var dateFieldValue= Xrm.Page.getAttribute('effectivefrom').getValue();

    Thanks

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Populating the Effective Date

    Still having problems.

    This is what I have done.

    In the Quote Form I click on Form Properties and add this info

    6825.Capture.PNG

    I then double clicked on Effective From and added this info

    6825.Capture.PNG

    1538.Capture1.PNG

    Saved it and Published.

    Any help would be awesome

  • Verified answer
    Mahendar Pal Profile Picture
    Mahendar Pal 45,095 on at
    RE: Populating the Effective Date

    Hi,

    Follow below steps:

    1. Open Form Editor and double click on first date field to open it's properties.

    2. Click on Event Tab->Click on Add->Select your web resource (new_EffectiveDate i think) under library drop down

    onchange.png

    3. Past your function name under Function for example SetDueDateField (make sure without ()  )

    4. Save and publish your changes

    Now as soon as you will set your first date it should populate second date field base on the above logic.

    Let us know if you need more information.

    Thanks

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Populating the Effective Date

    A little lost on this, is there a link for this or can you please explain a little more about this.

  • Mahendar Pal Profile Picture
    Mahendar Pal 45,095 on at
    RE: Populating the Effective Date

    Surly you need to call your method to some event like on OnChange of the effective To or OnSave of the form, so add event handler for your first field or for form OnSave

    Thanks

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Populating the Effective Date

    I made changes that Guido recommend, but it still not working.

    I do not have anything in function within the Parameters or Non-Event Dependencies

    0880.Capture.PNG

    Do I need an event Handler?

    If so what is it.

  • awalters Profile Picture
    awalters 3,079 on at
    RE: Populating the Effective Date

    Clever workaround - that hadn't occurred to me.  Thanks!

  • Mahendar Pal Profile Picture
    Mahendar Pal 45,095 on at
    RE: Populating the Effective Date

    Hi,

    There is not direct formula to get current date, but as the requirement is to set effective date as current date, so Created On can be copied to Start, by selecting Field option under Set Default value action.

    createdon.png

    Thanks

  • awalters Profile Picture
    awalters 3,079 on at
    RE: Populating the Effective Date

    The business rule adds the 60 from start, but can a business rule do the other half - fill in today's date for start?

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey Pt 2

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,569 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans