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 :
Customer experience | Sales, Customer Insights,...
Answered

Uncaught (in promise) ReferenceError: L is not defined in javascript

(0) ShareShare
ReportReport
Posted on by 267

Hello Team,

In below code i m getting error like Uncaught (in promise) ReferenceError: L is not defined in javascript 

Xrm.WebApi.online.retrieveMultipleRecords("msdyn_contractlinescheduleofvalue", "?$select=msdyn_contractlinelineid&$filter=msdyn_contractlinelineid eq "+ L-001006-D +"").then(
function success(result) {

if (result.entities.length > 0)
{
alert("Record Found");
}



},
function (error) {
console.log(error.message);
}

);

The issue is i have pass LineID(L-001006-D) in filter but script as count special character and can you suggest me solution for this problem.

I have the same question (0)
  • Suggested answer
    Guido Preite Profile Picture
    54,084 Moderator on at
    RE: Uncaught (in promise) ReferenceError: L is not defined in javascript

    problem is with the syntax, however I am not quite sure that msdyn_contractlinelineid is a text field, looks like a lookup field to me. If you use my tool Dataverse REST Builder (link in my signature, managed solution or xrmtoolbox version) you can generate the exact Retrieve Multiple syntax you need for Xrm.WebApi.online.retrieveMultipleRecords

  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator on at
    RE: Uncaught (in promise) ReferenceError: L is not defined in javascript

    Hi,

    Indeed, msdyn_contractlinelineid  is a lookup field as per microsoft docs.

    docs.microsoft.com/.../msdyn_contractlinescheduleofvalue

    L-001006-D -> Is this Contract Line Name field value??

    If yes then you will have to use expand query to filter your record based on Lookup Entity Name field.

    docs.microsoft.com/.../query-data-web-api

    You can use tool mentioned in above post.

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

  • Ashik Patel Profile Picture
    267 on at
    RE: Uncaught (in promise) ReferenceError: L is not defined in javascript

    Hello Bipin,

    Thanks for your suggestion  below my code for filter msdyn_contractlinelineid  and msdyn_contractlinelineid  is text field but write now this is not working

    Xrm.WebApi.online.retrieveMultipleRecords("msdyn_contractlinescheduleofvalue", "?$select=msdyn_contractlinelineid&$filter=msdyn_contractlinelineid eq "+ msdyn_orderlinenumber +"").then(

    function success(result) {

    if (result.entities.length > 0)
    {

    alert("Record Found");
    return;
    }
    else
    {
    alert("Record Not Found");
    Xrm.Utility.alertDialog("Next Stage is not allowed");
    executionContext.getEventArgs().preventDefault();

  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator on at
    RE: Uncaught (in promise) ReferenceError: L is not defined in javascript

    Hi,

    What error are you getting?

    Please see my previous reply -

    msdyn_contractlinelineid  is a lookup field as per microsoft docs.

    But you are saying it is a text field, Can you please reconfirm that?

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

  • Ashik Patel Profile Picture
    267 on at
    RE: Uncaught (in promise) ReferenceError: L is not defined in javascript

    6445.Untitled.png

    Hello Bipin 

    in this image show highlight field this is a Text field 

  • Ashik Patel Profile Picture
    267 on at
    RE: Uncaught (in promise) ReferenceError: L is not defined in javascript

    Code:

    var req = new XMLHttpRequest();

    req.open("GET",globalContext.getClientUrl() +"/api/data/v9.1/msdyn_projectcontractlinemilestones?$select=_msdyn_contractlineid_value&$filter=_msdyn_contractlineid_value eq " + L-001006-D + "", true);

    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)

    {

    alert("Hello");

    var result = JSON.parse(this.response);

    var _msdyn_contractlineid_value = result["_msdyn_contractlineid_value"];

    var _msdyn_contractlineid_value_formatted = result["_msdyn_contractlineid_value@OData.Community.Display.V1.FormattedValue"];

    var _msdyn_contractlineid_value_lookuplogicalname = result["_msdyn_contractlineid_value@Microsoft.Dynamics.CRM.lookuplogicalname"];

    alert(_msdyn_contractlineid_value);

    if(_msdyn_contractlineid_value != null)

    {

    alert("Record Found");

    }

    }

    else

    {

    Xrm.Utility.alertDialog(this.statusText);

    }

    }

    };

    req.send();

    }

  • Ashik Patel Profile Picture
    267 on at
    RE: Uncaught (in promise) ReferenceError: L is not defined in javascript

    URL:

    Testcrm8.dynamics.com/.../msdyn_projectcontractlinemilestones eq 'L-001006-D'

    Error :

    {"error":{"code":"0x0","message":"A binary operator with incompatible types was detected. Found operand types 'Edm.Guid' and 'Edm.String' for operator kind 'Equal'."}}

    I have only LineId from Order Line Entity  and i want to check this LineId is Exist or not in   Project Contract Line Milestone entity  

  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator on at
    RE: Uncaught (in promise) ReferenceError: L is not defined in javascript

    HI,

    As per your image highlighted field schema name is msdyn_contractlinelineid with double line but in your code you have _msdyn_contractlineid_value with single line which is a lookup field with display name Project Control Line from your image.

    Please update correct field schema name in your code and it will work.

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

  • Ashik Patel Profile Picture
    267 on at
    RE: Uncaught (in promise) ReferenceError: L is not defined in javascript

    Now i have updated

    Xrm.WebApi.online.retrieveMultipleRecords("msdyn_contractlinescheduleofvalue", "?$select=msdyn_contractlinelineid&$filter=msdyn_contractlinelineid eq "+ L-001006-D +"").then(

    function success(result) {

    if (result.entities.length > 0)

    {

    alert("Record Found");

    return;

    }

    else

    {

    alert("Record Not Found");

    Xrm.Utility.alertDialog("Next Stage is not allowed");

    executionContext.getEventArgs().preventDefault();

    }

    but still not working

  • Verified answer
    Bipin D365 Profile Picture
    28,983 Moderator on at
    RE: Uncaught (in promise) ReferenceError: L is not defined in javascript

    Hi,

    Syntax is inccorect.

    Please try below code -

    Xrm.WebApi.online.retrieveMultipleRecords("msdyn_contractlinescheduleofvalue", "?$select=msdyn_contractlinelineid&$filter=msdyn_contractlinelineid eq 'L-001006-D'").then(

    function success(result) {

    if (result.entities.length > 0)

    {

    alert("Record Found");

    return;

    }

    else

    {

    alert("Record Not Found");

    Xrm.Utility.alertDialog("Next Stage is not allowed");

    executionContext.getEventArgs().preventDefault();

    }

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 > Customer experience | Sales, Customer Insights, CRM

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 228

#2
Tom_Gioielli Profile Picture

Tom_Gioielli 156 Super User 2025 Season 2

#3
MVP-Daniyal Khaleel Profile Picture

MVP-Daniyal Khaleel 149

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans