web
You’re offline. This is a read only version of the page.
close
Skip to main content
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

I have the same question (0)
  • Adrian Begovich Profile Picture
    1,027 Moderator 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?

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator 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.

  • Microsoft Dynamics 365 Consultancy Profile Picture
    297 on at
    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);

  • Community Member Profile Picture
    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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

#3
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans