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...
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

I have the same question (0)
  • Suggested answer
    Priyesh Profile Picture
    7,396 User Group Leader on at

    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.

  • Mattw112b Profile Picture
    387 on at

    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

  • Community Member Profile Picture
    on at

    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?

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
Martin Dráb Profile Picture

Martin Dráb 47 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 38 Super User 2025 Season 2

#3
#ManoVerse Profile Picture

#ManoVerse 31

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans