jscript error: Unable to get value of the property 'getValue': object is null or undefined.
-
sexta-feira, 18 de maio de 2012 15:13
Trying to leverage code we created. This code works in one deployment, but gives the above error (onLoad) in a second deployment. Any ideas?
function Form_onload()
{
var CRM_FORM_TYPE_CREATE = 1;
var CRM_FORM_TYPE_UPDATE = 2;
var CRM_FORM_TYPE_READONLY = 3;
var CRM_FORM_TYPE_DISABLED = 4;
var CRM_FORM_TYPE_BULKEDIT = 6;
var CRM_FORM_TYPE_UNDEFINED = 0;
var Statecode = Xrm.Page.getAttribute("statecode").getValue();if (Statecode =='Resolved'|| Statecode == 'Canceled')
{
alert('Do nothing');
}
else if((Xrm.Page.ui.getFormType() == CRM_FORM_TYPE_UPDATE || Xrm.Page.ui.getFormType() == CRM_FORM_TYPE_READONLY || Xrm.Page.ui.getFormType() == CRM_FORM_TYPE_DISABLED) )
{var oneMinute = 60 * 1000;
var oneHour = oneMinute * 60;
var oneDay = oneHour * 24;var today = new Date();
if (Xrm.Page.getAttribute("createdon").getValue() != null)
var diff = today.getTime() - Xrm.Page.getAttribute("createdon").getValue().getTime();
diff = Math.floor(diff/oneDay);
Xrm.Page.getAttribute("new_daysinprocess").setValue(diff);
}
}Ken Compter
- Movido Andrii ButenkoMVP, Moderator sexta-feira, 18 de maio de 2012 15:27 (From:CRM)
Todas as Respostas
-
sexta-feira, 18 de maio de 2012 15:32ModeradorDid you try to debug your code ??
Mahain : Check My Blog
Follow me on Twitter
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question. -
sexta-feira, 18 de maio de 2012 18:18
Can you check if you have all the fields mentiond in this script are added in "Dependent fields"? (Form Properties --> Event handlers --> Edit --> Dependencies tab)
-
sexta-feira, 18 de maio de 2012 19:56
Hello kcompter:
First thing, check whether the fields you are trying to get value are present in the form not in the unused fields.
If it is fine for you, tell me at which line of your code, you are getting the error.?
Saurabh Gupta, MS CRM 2011 Software Development Engineer
- Marcado como Resposta kcompter sexta-feira, 18 de maio de 2012 20:39
-
sexta-feira, 18 de maio de 2012 20:36In which line of code you are getting the error ?
-
sexta-feira, 18 de maio de 2012 20:39
That was the answer! Sometimes it is always the simple things. Thank you all for sending suggestions!
Ken
Ken Compter