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 385

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
    Community Member Microsoft Employee 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
    Mattw112b 385 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
    Priyesh 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 Our 2025 Season 1 Super Users!

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

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,399 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans