locked
Customization error RRS feed

  • Question

  • On a custom entity, I am trying to set a default user in a lookup field and I get an error.  My code is correct (I think) and the error message does not point at the web resource but a general error.  Any suggestions are appreciated.

    function ApprovalAuthority_oncreate()
    {
    var FormType = Xrm.Page.ui.getFormType();
    if(FormType == 1)
       {
          var lookup = new Array();
          lookup[0] = new Object();
          lookup[0].id = 'F2B24C50-E923-E011-8A83-00155D7F7F04';
          lookup[0].name = 'Full Name';
          lookup[0].entityType = 8;
          Xrm.Page.getAttribute("new_approvalauthority").setValue(lookup);
       }
    }

    Error:

    Microsoft Dynamics CRM Error Report Contents

    <CrmScriptErrorReport>
      <ReportVersion>1.0</ReportVersion>
      <ScriptErrorDetails>
       <Message>Unable to get property 'setValue' of undefined or null reference</Message>
       <Line>1</Line>
       <URL>/_static/_common/scripts/PageLoader.js?ver=1849683925</URL>
       <PageURL>/main.aspx?etc=10021&extraqs=%3fetc%3d10021%26pagemode%3diframe%26preloadcache%3d1373470420404&pagetype=entityrecord</PageURL>
       <Function>executeAction(action)</Function>
       <CallStack>
        <Function>executeAction(action)</Function>
       </CallStack>
      </ScriptErrorDetails>
      <ClientInformation>
       <BrowserUserAgent>Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.2; WOW64; Trident/6.0; Touch; .NET4.0E; .NET4.0C; .NET CLR 3.5.30729; .NET CLR 2.0.50727; .NET CLR 3.0.30729; Tablet PC 2.0; InfoPath.3; BRI/2; IPH 1.1.21.4019)</BrowserUserAgent>
       <BrowserLanguage>en-US</BrowserLanguage>
       <SystemLanguage>en-US</SystemLanguage>
       <UserLanguage>en-US</UserLanguage>
       <ScreenResolution>1600x900</ScreenResolution>
       <ClientName>Web</ClientName>
       <ClientTime>2013-07-10T11:33:42</ClientTime>
      </ClientInformation>
      <ServerInformation>
        <OrgLanguage>1033</OrgLanguage>
        <OrgCulture>1033</OrgCulture>
        <UserLanguage>1033</UserLanguage>
        <UserCulture>1033</UserCulture>
        <OrgID>{7C14739F-21C2-E211-A794-00155D212419}</OrgID>
        <UserID>{1E7A6274-85F5-DF11-8A83-00155D7F7F04}</UserID>
        <CRMVersion>5.0.9690.3448</CRMVersion>
      </ServerInformation>
    </CrmScriptErrorReport>

     


    Ken Compter

    Wednesday, July 10, 2013 3:34 PM

All replies

  • Hi,
    try to put systemuser as entityType:

    function ApprovalAuthority_oncreate()
    {
    var FormType = Xrm.Page.ui.getFormType();
    if(FormType == 1)
       {
          var lookup = new Array();
          lookup[0] = new Object();
          lookup[0].id = 'F2B24C50-E923-E011-8A83-00155D7F7F04';
          lookup[0].name = 'Full Name';
          lookup[0].entityType = 'systemuser';
          Xrm.Page.getAttribute("new_approvalauthority").setValue(lookup);
       }
    }


    My blog: www.crmanswers.net

    Wednesday, July 10, 2013 3:38 PM
  • Same error message when using 'systemuser'.  What is strange is that there is no setValue in the code at all and only the function on line 1, and it references static/_common/scripts/PageLoader.js?ver=1849683925.  Usually if there is a code error it ids the web resource and line #.

    Ken Compter

    Wednesday, July 10, 2013 5:13 PM
  • 
    try by adding Braces in id as{F2B24C50-E923-E011-8A83-00155D7F7F04}
    function ApprovalAuthority_oncreate()
    {
    var FormType = Xrm.Page.ui.getFormType();
    if(FormType == 1)
       {
          var lookup = new Array();
          lookup[0] = new Object();
          lookup[0].id = '{F2B24C50-E923-E011-8A83-00155D7F7F04}';
          lookup[0].name = 'Full Name';
          lookup[0].entityType = 'systemuser';
          Xrm.Page.getAttribute("new_approvalauthority").setValue(lookup);
       }
    }


    Muhammad Sohail

    Friday, July 12, 2013 6:13 AM
  • Hi,

    Check the field name is correct or not.

    Xrm.Page.getAttribute("new_approvalauthority").setValue(lookup);


    Thanks, Ranjan,Dynamics CRM Developer

    Friday, July 12, 2013 7:55 AM
  • The error indicates that your 'new_approvalauthority' field cannot be found, which means the field name is either spelled wrong, or the field is not on your form.

    Since it's a lookup field perhaps you are missing the 'id' suffix on the field name?

    Hope that helps

    Paul


    If my response helped you find your answer please show your thanks by taking the time to "Mark As Answer" and "Vote As Helpful".

    Twitter LinkedIn Facebook Blog Magnetism

    Friday, July 12, 2013 12:17 PM