web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
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 277

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,086 Moderator on at

    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,985 Moderator on at

    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
    277 on at

    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,985 Moderator on at

    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
    277 on at

    6445.Untitled.png

    Hello Bipin 

    in this image show highlight field this is a Text field 

  • Ashik Patel Profile Picture
    277 on at

    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
    277 on at

    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,985 Moderator on at

    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
    277 on at

    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,985 Moderator on at

    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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 180 Super User 2026 Season 1

#2
11manish Profile Picture

11manish 123

#3
CU11031447-0 Profile Picture

CU11031447-0 100

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans