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

Announcements

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Cannot run the script to get lookup entity id.

(0) ShareShare
ReportReport
Posted on by 2

Hello'

I have successfully run the onLoad webresource in Case form to get Subject entity's GUID through lookup field---subjectid. Now Subject entity is replaced by a custom entiy, named Category, my purperse is get the Category entity's GUID throught run a webresource when loading Case record. The code as below:

function getCategoryLookupId(executionContext) {

    debugger;

    var formContext = executionContext.getFormContext();

    var lookupObjValue = formContext.getAttribute("abc_opscategory").getValue();

    if (lookupObjValue != null) {

        var categoryId = lookupObjValue[0].id;

        if (categoryId != null) {

            Xrm.Utility.alertDialog("Category ID: " + categoryId);

        }
    }
}

When loading Case form, I have encounter an issue, lookupObjValue always is null. the screen as below

pastedimage1679025855588v1.png

Appreciated for your help!

I have the same question (0)
  • Verified answer
    Leah Ju Profile Picture
    Microsoft Employee on at

    Hi Partner,

    Checking the logic name of the Category lookup column:

    pastedimage1679047166090v1.png

    Ans ensure that the Category lookup and js are added to the same form.

  • ALAN365 Profile Picture
    2 on at

    Hi Leah,

    Thank you for your response. I've checked the lookup field logic name, it's correct and this custom lookup field and JS script are also located in same form, the issue still exist. In the same form an OOB lookup field "Subject", I can use same script to get Subject entity's GUID. The only different is one is custom entity, another one is OOB entity. What happen? Would you please give me advice?

  • ALAN365 Profile Picture
    2 on at

    Stupide reason cause the "issue", LOL. --- The lookup field in Case form should have lookup record!!!

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 > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 69 Super User 2026 Season 1

#2
BillurSamdancioglu Profile Picture

BillurSamdancioglu 55 Most Valuable Professional

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 55 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans