Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Issue with getting attribute value on form load

Posted on by 5

Hi, 

I am trying to create validation onLoad that if a certain required field has a value, then hide it. I am using the following code to see if the field has a value:

var productInterestValue = formContext.getAttribute("znl_productinterest").getValue;

However, when I log the variable however it displays:

getValue(){const e="ClientApi.XrmEntityAttributeOptionSet.getValue";try{s.a.instance.reportCall(e);const t=this.getValueInternal(),n=Object(D.g)(t),r=Object(f.a)(n)?Object(D.f)(t,this.getAttributeType(),0):n;return s.a.instance.reportSuccess(e),r}catch(t){const n=v.a.getInstance().getEventParameters(this.contextToken);throw n.push({name:"attributeName",value:this.getName()}),v.a.getInstance().reportFailure(e,t,null,n),t}}

I'm pretty new to dynamics, so any help would be appreciated!

Thanks,

Joe

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Issue with getting attribute value on form load

    I am glad that was it Joe!

    Please mark it as answered then.

  • joecampbelluk Profile Picture
    joecampbelluk 5 on at
    RE: Issue with getting attribute value on form load

    Knew it would be something simple! Thanks so much, hopefully this answer stops someone else asking a silly question in the future!

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Issue with getting attribute value on form load

    just add "()" to getValue, like this:

    var productInterestValue = formContext.getAttribute("znl_productinterest").getValue();

    When you don't add the parentheses you are asking to retrieve the function definition instead of actually calling it.

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