Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

please translate it to v9.0 for dynamics CRM

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

please translate it to v9.0 for dynamics CRM

function Form_onload() {
    var setUservalue = new Array();
 setUservalue[0] = new Object();
 setUservalue[0].id = Xrm.Page.context.getUserId();
 setUservalue[0].entityType = 'systemuser';
setUservalue[0].name = Xrm.Page.context.getUserName();
 
Xrm.Page.getAttribute("from").setValue(setUservalue)
    }//

*This post is locked for comments

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: please translate it to v9.0 for dynamics CRM

    I can't find any difference in the code script you suggested above and previously. Please follow the above suggestions.

    I also replied to your other thread with the links on "How to debug JavaScript" which may help you fixing this issue as well. If this still doesn't work. Follow the below blog on JavaScript basics and get yourself familiar.

    https://neilparkhurst.com/2015/12/01/javascript-basics/

    Hope this helps.

  • a33ik Profile Picture
    a33ik 84,325 Most Valuable Professional on at
    RE: please translate it to v9.0 for dynamics CRM

    No duplicated threads, please.

  • Suggested answer
    gdas Profile Picture
    gdas 50,089 on at
    RE: Form_onload is not defined at eval

    Hi ,

    Following things you need to check-

    1. Make sure you publish your  forms and reload forms.

    2.  Copy all the code from webresource and paste it in Visual Studio JavaScript file , see is there any additional brackets or missing brackets in other function.

    3. When you registered your function in the form onload make sure you are passing execution context.

    4.Make sure you define the function

    "RetrieveUserById".

    5.what is the attribute called "form.

    Do you have any fields in the entity with same name.

    formContext.getAttribute("from").

    6. Make sure you added the library in the forms and also you choose right web resource name while register the onload function.

    7. Press CTRL+ F5 to refresh the forms after publish.

    Hope above steps will helps you.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    Form_onload is not defined at eval

    This the function that i had written but it showing an error on load as, Form_onload is not defined at eval

    function Form_onload(executionContext)

    {

    var globalContext = Xrm.Utility.getGlobalContext();

     var formContext = executionContext.getFormContext();  

    var CurrentUser = globalContext.userSettings.userId;

    var setUservalue = RetrieveUserById(globalContext,CurrentUser);  

    var fullname = setUservalue.UserName;  

    var id= setUservalue.UserId;  

    var enitytype = formContext.data.entity.getEntityName();

    formContext.getAttribute("from").setValue(setUservalue);

    }

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: please translate it to v9.0 for dynamics CRM

    Just noticed that you are calling some other method in your script RetrieveUserById. Ensure that you have this method in your liabrary.

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: please translate it to v9.0 for dynamics CRM

    Hi,

    The error can happen for 2 reason 1) If there is any syntax error 2) If the browser is still loading the old/cached version.

    There doesn't seem to be any syntax error in your code so it should be fine. Ensure that you are also passing the context from form. docs.microsoft.com/.../clientapi-execution-context

    Also, ensure that you have done publish all customization and refresh form. If it still doesn't work try it on an inprivate/ incognito mode.

    Hope this helps.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: please translate it to v9.0 for dynamics CRM

    Hi Ravi,

    first up all my apologies,

    This the function that i had written but it showing an error on load as, Form_onload is not defined at eval

    function Form_onload(executionContext)

    {

     var globalContext = Xrm.Utility.getGlobalContext();

     var formContext = executionContext.getFormContext();

     var CurrentUser = globalContext.userSettings.userId;

     var setUservalue = RetrieveUserById(globalContext,CurrentUser);

     var fullname = setUservalue.UserName;

      var id= setUservalue.UserId;

      var enitytype = formContext.data.entity.getEntityName();

    formContext.getAttribute("from").setValue(setUservalue);

    }

  • RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: please translate it to v9.0 for dynamics CRM

    Hi Mahesh917,

    Community members are here to assist you/ help you fix your issue by providing suggestions/ answers ( And not for these kind of requests). Please review the link shared above and convert it yourself. If you face any issue, please feel free to post here.

  • Suggested answer
    Daniel Wikell Profile Picture
    Daniel Wikell 2,360 on at
    RE: please translate it to v9.0 for dynamics CRM

    Hi

    See this documentation for how to replace Xrm.Page with the new form context: docs.microsoft.com/.../clientapi-form-context

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,387 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans