Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

ReferenceError: Sdk is not defined at eval

(0) ShareShare
ReportReport
Posted on by 297

Hello Everyone !

I hope that all of you are happy. I created a JS web resource which execute when form on load so when form loads "ReferenceError: Sdk is not defined at eval" error occurs. Can anyone tell me how to resolve this issue?

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: ReferenceError: Sdk is not defined at eval

    Hi,

    I am currently getting a similar error message, can you please share the solution you used to resolve this?

    CR

  • RE: ReferenceError: Sdk is not defined at eval

    Following is the error

    query-to-post.PNG

    Following is my code: 

    // A namespace defined for the sample code
    // As a best practice, you should always define
    // a unique namespace for your libraries
    var Sdk = window.Sdk || {};
    (function () {
    // Code to run in the form OnLoad event
    this.formOnLoad = function (executionContext) {
    alert("hello world");
    var rolename;
    var count = 0;
    var formContext = executionContext.getFormContext();
    var userSettings = Xrm.Utility.getGlobalContext().userSettings;
    var currentUserRoles = userSettings.securityRoles;

    for (var i = 0; i < currentUserRoles.length; i++) {
    rolename = getUserRoleName(currentUserRoles[i]);
    if (rolename == “CMS User”) {
    formContext.getControl("prioritycode").setDisabled(true);
    formContext.getControl("scheduledend").setDisabled(true);
    }
    }
    }

    function getUserRoleName(Roleid) {
    var name;
    var globalContext = Xrm.Utility.getGlobalContext();
    var req = new XMLHttpRequest();
    req.open(“GET”, globalContext.getClientUrl() + “/api/data/v9.1/roles?$select=name&$filter=roleid eq ” + Roleid, false);
    req.setRequestHeader(“OData-MaxVersion”, “4.0”);
    req.setRequestHeader(“OData-Version”, “4.0”);
    req.setRequestHeader(“Accept”, “application/json”);
    req.setRequestHeader(“Content-Type”, “application/json; charset=utf-8”);
    req.setRequestHeader(“Prefer”, “odata.include-annotations=\”*\””);
    req.onreadystatechange = function () {
    if (this.readyState === 4) {
    req.onreadystatechange = null;
    if (this.status === 200) {
    var results = JSON.parse(this.response);
    for (var i = 0; i < results.value.length; i++) {
    name = results.value[i][“name”];

    }
    } else {
    // Xrm.Utility.alertDialog(this.statusText);
    }
    }
    };
    req.send();
    return name;
    }

    }).call(Sdk);

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: ReferenceError: Sdk is not defined at eval

    Hi,

    It appears that you are using some helper libraries REST/ SOAP from SDK which you haven't referenced in your form. Add the reference of the related liabrary, publish and try again.

    If still not resolved, you need to share your code/ screenshot as mentioned above.

    Hope this helps.

  • Adrian Begovich Profile Picture
    Adrian Begovich 1,019 Super User 2025 Season 1 on at
    RE: ReferenceError: Sdk is not defined at eval

    Hi Microsoft Dynamics 365 Consultancy,

    Can you please post a screenshot of your error message and the JavaScript code?

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,489 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans