Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 82002

Friday Puzzle - What wrong with this JavaScipt?

$
0
0

Been trying to figure out why this wont work for a while and cant figure out whats wrong because I dont get any errors so the syntax must be right..

I think it has something to do with this line for "endDate"

         endDate.setDate(endDate.getDate() + 4);

Here the full code:

function SetDate() {

   if (Xrm.Page.ui.getFormType() == 1) {

       var dueDate = Xrm.Page.data.entity.attributes.get("new_date");

       var now = new Date();

       var endDate = new Date();

       endDate.setDate(now.getDate() + 3);

       if (endDate.getDay() == 5) {

           endDate.setDate(endDate.getDate() + 4);

       }

       if (endDate.getDay() == 6) {

           endDate.setDate(endDate.getDate() + 5);

           dueDate.setValue(endDate);

       }

   }

}

   function Form_OnLoad() {

       if (Xrm.Page.ui.getFormType() == 2) {

           if (Xrm.Page.getAttribute("new_date").getValue() != null) {

               Xrm.Page.ui.controls.get("new_date").setDisabled(true);

           }

       }

   }


Viewing all articles
Browse latest Browse all 82002

Trending Articles