var FORM_TYPE_CREATE = 1;
var FORM_TYPE_UPDATE = 2;
var FORM_TYPE_READ_ONLY = 3;
var FORM_TYPE_DISABLED = 4;
var FORM_TYPE_QUICK_CREATE = 5;
var FORM_TYPE_BULK_EDIT = 6;
// get current TYPE and use it when u what it to run
var formType = Xrm.Page.ui.getFormType();
// if you want to use it on save
if (formType == FORM_TYPE_CREATE) {
}
else {
}


/note: if you want your javascript not to work when saved 1st time and only work on update

if (formType == FORM_TYPE_UPDATE)
  


SOURCE : JUST2CODE.IN
Subscribe to our YouTube channel : https://www.youtube.com/user/TheRussell2012