jueves, 12 de septiembre de 2013

CRM 4.0 - Crear variables aleatorias diferentes con javascript (sacado de otro blog)

/* OnLoad Event */
/*
* Zero-pad a number if the value is less
* than 10.
*/
function ZeroPad(st) {
 var temp = "";
 if (st < 10) {
  temp += '0';
 }
 temp += st.toString();
 return temp;
}

/*
* Build a new Change Number based on
* the current Date and Time.
*/

function BuildChangeNumber() {
 var currentDate = new Date();
 var currentDay = currentDate.getUTCDate();
 var currentMonth = currentDate.getUTCMonth();
 var currentHour = currentDate.getUTCHours();
 var currentMinute = currentDate.getUTCMinutes();
 var currentSecond = currentDate.getUTCSeconds();
 var tempDate = currentDate.getUTCFullYear()
 tempDate += ".";
 tempDate += ZeroPad(currentMonth);
 tempDate += ZeroPad(currentDay);
 tempDate += ".";
 tempDate += ZeroPad(currentHour);
 tempDate += ZeroPad(currentMinute);
 tempDate += ZeroPad(currentSecond);
 // alert(tempDate);
 return tempDate;
}
var CRM_FORM_TYPE_CREATE = 1;
/*
* If this is a New record, then populate the
* Change Number field.
*/
if (crmForm.FormType == CRM_FORM_TYPE_CREATE) {
 window.document.all.new_name.DataValue = BuildChangeNumber();
}

No hay comentarios:

Publicar un comentario