Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Script Error: Web resource method does not exist

(0) ShareShare
ReportReport
Posted on by

Hello,

When I built an onLoad websuorce, error message:

ReferenceError: Web resource method does not exist: getSubjectLookupId
Error Details:
Event Name: onload
Function Name: getSubjectLookupId
Web Resource Name: abc_casesubjectidlookup.js
Solution Name: Active
Publisher Name: DefaultPublisherxxxx

I'd like get the Subject entity's GUID (lookup field) when I load the Case entity form. My script:

function getSubjectLookupId(executionContext) {

debugger;

var formContext = executionContext.getFormContext();

var lookupObj = formContext.getAttribute("subjectid"); //Check for Lookup Object

if (lookupObj != null) {

var lookupObjValue = lookupObj.getValue(); //Check for Lookup Value

if (lookupObjValue != null) {

var subjectId = lookupObjValue[0].id, // To get record GUID

if (subjectId != null) {

Xrm.Utility.alertDialog("ID: " + subjectId);

}
}
}
}

Could you please help to analyze what cause the error? Thanks.

  • ALAN365 Profile Picture
    ALAN365 on at
    RE: Script Error: Web resource method does not exist

    Thank you so much  Steve!

    It's work. You found the typo.

    I have encounter another issue, almost same script but lookup a custom entity, The lookupObj always undefined. I will post another tread. Please review it.

  • Verified answer
    Steve Zhao2 Profile Picture
    Steve Zhao2 on at
    RE: Script Error: Web resource method does not exist

    Hi ALL365,

    This is due to there is a syntax error in your script. You should change the comma to semicolon at this line: var subjectId = lookupObjValue[0.id,

    So please try this code:

    function getSubjectLookupId(executionContext) {
    
    debugger;
    
    var formContext = executionContext.getFormContext();
    
    var lookupObj = formContext.getAttribute("subjectid"); //Check for Lookup Object
    
    if (lookupObj != null) {
    
    var lookupObjValue = lookupObj.getValue(); //Check for Lookup Value
    
    if (lookupObjValue != null) {
    
    var subjectId = lookupObjValue[0].id; // To get record GUID
    
    if (subjectId != null) {
    
    Xrm.Utility.alertDialog("ID: "   subjectId);
    
    }
    }
    }
    }

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,711 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans