Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 general forum
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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,537 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,520 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans