Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

Buttons and Javascript

(0) ShareShare
ReportReport
Posted on by 387

I've approached this many ways, frustrating that I have spent so long trying to get this working, seems like it should be easy.

I want a button on a form that when I click it it changes the value of a field.

I have tried the pcf control, wont do anything.  Not sure if it is broke or what.

I have created a simple html button that onclick launches a javascript function, which I've added to the form library as a jscript resoruce.  But it does nothing.

Is there any place else I need to add soemthing?

I am seeing an error in debugger that the function name is not defined.  But I don't see what else I can do to 'define' this?  If I have the js in library, and the html button onclick calls that function name, what do I do to 'define' it?

Thanks,

Terry

  • Community Member Profile Picture
    on at
    RE: Buttons and Javascript

    Please post the code you've written for the button (both the HTML and the JS).

    Where is your javascript code written? is it written as a script inside the HTML file?

  • Mattw112b Profile Picture
    387 on at
    RE: Buttons and Javascript

    yes/no doesn't work in my situation where I have the button adding text and appending to another field multiple times...

    Finally after trying too many times, I ended up using Ribbon work bench instead and put the button in the ribbon and attached code that way... which worked in classic, but not unified... so then had to spend hours searching around to figure out how to get working in both.. which I did, but man shouldn't have had to spend my entire Saturday getting a simple button working.

    Microsoft really needs to make these things easier.  Adding a button on the form?!, that onClick does something?  I mean come on.. that is like pretty basic for any toolset going back 30 years.  Seems weird that you have to do all sorts of work arounds and other 3rd party tools and code and then configuration work arounds (primaryControl vs executioncontrol), etc. ridiculous.

    Thanks,

    Terry

  • Suggested answer
    Priyesh Profile Picture
    7,396 User Group Leader on at
    RE: Buttons and Javascript

    Hi,

    If it doesn't matterhow the button is put on the form, I suggest you simply put a Two Option (Yes/No) field on the form and write Business Rule to do your task.

    This should run when you set the field to Yes.

    The first step in the Business Rule is to check if the button value is Yes.

    And the last step in the Business Rule should set the value back to No (this won't trigger the logic again since you are checking for True value in the first step mentioned above and this will also make the field available for Next use).

    Hope this somewhat helps.

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

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

#1
Siv Sagar Profile Picture

Siv Sagar 149 Super User 2025 Season 1

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 61 Most Valuable Professional

#3
Daivat Vartak (v-9davar) Profile Picture

Daivat Vartak (v-9d... 53 Super User 2025 Season 1

Overall leaderboard

Product updates

Dynamics 365 release plans