Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Cannot run the script to get lookup entity id.

Posted on by

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!

  • ALAN365 Profile Picture
    ALAN365 on at
    RE: Cannot run the script to get lookup entity id.

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

  • ALAN365 Profile Picture
    ALAN365 on at
    RE: Cannot run the script to get lookup entity id.

    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?

  • Verified answer
    Leah Ju Profile Picture
    Leah Ju Microsoft Employee on at
    RE: Cannot run the script to get lookup entity id.

    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.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans