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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

Lookup test for null

(0) ShareShare
ReportReport
Posted on by 515

Hi

I'm doing a simple test for null in JavaScript of a lookup field. I'm getting an error every time.

Can someone tell me what my obvious error is?

Every time my error message is Cannot read property 'getValue' of null

        if (leadsource != null) {
            leadsource= fc.getAttribute("leadsource").getValue()[0].name;
        }

I've also tried

        if (leadsource != null || leadsource.length > 0) {
            leadsource= fc.getAttribute("leadsource").getValue()[0].name;
        }

and

        if (leadsource != null || leadsource.length > 0 ||  leadsource == undefined) {
            leadsource= fc.getAttribute("leadsource").getValue()[0].name;
        }

Thanks

Lee

I have the same question (0)
  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello Lee,

    Can you please provide the full code? Can you please confirm that field 'leadsource' is on the form? It seems that this leadsource field is out-of-box. What entity is it on?

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Siv Sagar Profile Picture

Siv Sagar 93 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 80

#3
Martin Dráb Profile Picture

Martin Dráb 64 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans