Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

Getting error - as formContext.getAttribute.. is not a function

(0) ShareShare
ReportReport
Posted on by 140

Hello,

I have a java script function on load of the form which eventually calls - formContext.getAttribute("new_fieldame").addOnChange(fucntionname).

But on load of new lead form or existing lead form, following error is occurred -

formContext.getAttribute(...).addOnChange is not a function

This error was not occurring on other environment (having same JS, same form), however I could reproduce it by removing that field 'new_fieldname'.

On-load function gets called when complete form is loaded. However, I think the field is not getting loaded here.

Any idea about the occurrence of this error?

Thanks in advance.

  • Aarnav Profile Picture
    125 on at
    RE: Getting error - as formContext.getAttribute.. is not a function

    The form will pass global context , not the formContext , so you will need to get formcontext before calling getAttribute method.

    formContext.getFormContext().getAttribute("new_fieldname");
     assuming 'formContext' is the name of the argument in your function.

    [quote user="PD_0504"

    Hello,

    I have a java script function on load of the form which eventually calls - formContext.getAttribute("new_fieldame").addOnChange(fucntionname).

    But on load of new lead form or existing lead form, following error is occurred -

    formContext.getAttribute(...).addOnChange is not a function

    This error was not occurring on other environment (having same JS, same form), however I could reproduce it by removing that field 'new_fieldname'.

    On-load function gets called when complete form is loaded. However, I think the field is not getting loaded here.

    Any idea about the occurrence of this error?

    Thanks in advance.

    [/quote
  • Yiantheo Profile Picture
    5 on at
    RE: Getting error - as formContext.getAttribute.. is not a function

    I have the exact same issue, did you find a solution to this? mine is  formContext.getAttribute(Applikata.Grade.Fields.Exam(true)).addOnChange(CalculateResult); and the field is alright in the form

  • Verified answer
    a33ik Profile Picture
    84,329 Most Valuable Professional on at
    RE: Getting error - as formContext.getAttribute.. is not a function

    My recommendation - place it somewhere on the form and uncheck "Visible" checkbox in the properties - that should fix your issue.

  • snehaln676 Profile Picture
    140 on at
    RE: Getting error - as formContext.getAttribute.. is not a function

    I have the field on header of the form and not anywhere else on form. However I am accessing it with 'new_fieldname' only (instead of header_new_fieldname). It works on one environment, form gets loaded properly. But, it fails on another environment (replica of the 1st environment) where I get above mentioned error.

  • a33ik Profile Picture
    84,329 Most Valuable Professional on at
    RE: Getting error - as formContext.getAttribute.. is not a function

    Can you confirm that field is available on the form? Without field available on the form getAttribute will return null so your code will fail.

  • snehaln676 Profile Picture
    140 on at
    RE: Getting error - as formContext.getAttribute.. is not a function

    Hello Clofly,

    I have checked the field name and 'new_fieldname' is the logical name of the field.

  • cloflyMao Profile Picture
    25,202 on at
    RE: Getting error - as formContext.getAttribute.. is not a function

    Hi Partner,

    You could check whether "new_fieldname" is actually the logical name of that field.

    I recommend to use Level up for Dynamics 365/Power Apps plugin of Chrome, after the plugin has been installed,

    click the "logical name" menu to get logical name of all fields of form quickly.

    pastedimage1597389156546v1.png

    Regards,

    Clofly

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

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

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,001 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,837 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans