locked
How to Auto update Date field in CRM RRS feed

  • Question

  • Hi, 

         I have a custom entity with two custom fields "Lending Date" and "Due date" I want to create a JavaScript code which get date from Lending date field and update the Due date field after 21 days of Lending Date.

    For Example if Lending Date is "9/3/2014" then the Due date will be "30/3/2014".

    can anyone push me in right way....

    Thanx

    Friday, October 3, 2014 3:01 PM

Answers

  • you can use this simple javascript as example:

    function lendingOnChange() {
    var lendingDate = Xrm.Page.getAttribute("new_lendingdate").getValue();
    if (lendingDate == null) {
        Xrm.Page.getAttribute("new_duedate").setValue(null);
    } else {
        var dueDate = lendingDate;
        dueDate = dueDate.setDate(lendingDate.getDate() + 21);
        Xrm.Page.getAttribute("new_duedate").setValue(dueDate);
    }
    }


    My blog: www.crmanswers.net - Rockstar 365 Profile

    • Marked as answer by Mr.Yasir ali Friday, October 3, 2014 3:26 PM
    Friday, October 3, 2014 3:07 PM

All replies

  • you can use this simple javascript as example:

    function lendingOnChange() {
    var lendingDate = Xrm.Page.getAttribute("new_lendingdate").getValue();
    if (lendingDate == null) {
        Xrm.Page.getAttribute("new_duedate").setValue(null);
    } else {
        var dueDate = lendingDate;
        dueDate = dueDate.setDate(lendingDate.getDate() + 21);
        Xrm.Page.getAttribute("new_duedate").setValue(dueDate);
    }
    }


    My blog: www.crmanswers.net - Rockstar 365 Profile

    • Marked as answer by Mr.Yasir ali Friday, October 3, 2014 3:26 PM
    Friday, October 3, 2014 3:07 PM
  • Thanks Guido Preite,

    Its working fine.

    Thanks.


    Friday, October 3, 2014 3:27 PM