Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Adding a Button to a Form

Posted on by

Hi All,

I want to add a custom button next to a field in a Dynamics 365 form. So I have used the following code and follow the instructions here- 

 https://www.tutorialspoint.com/microsoft_crm/microsoft_crm_html_web_resources.htm

<html><head> 
<style>
.button {
    background-color: 00bfff;
    border: none;
    color: white;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 10px;
    cursor: pointer;
    border-radius: 6px;
}
</style>
<script>
function TestClick()
{
alert("clicked!");
}
</script>
<meta charset="utf-8"></head>
<body>
<button class="button" onclick="TestClick()">Click</button>
</body></html>
But the output is like this on the form
2577.form.png
Can someone please tell me what am I missing. What I actually want to do is when someone click on the button I want to execute a workflow, currently W/F is executing via a button in the ribbon. First i want to get display the button on the form.
Thanks.

*This post is locked for comments

  • Dineth Profile Picture
    Dineth on at
    RE: Adding a Button to a Form

    Hi Nithya,

    Yes it worked, but I have to add window.parent for .Xrm

    Thanks All.

  • Verified answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: Adding a Button to a Form

    Hi Dineth,

    Can you put the following script tag in your HTML web resource and see if it works.

    <script type="text/javascript" src="/WebResources/mag_/js/process.js"></script>

    Hope this helps.

  • Dineth Profile Picture
    Dineth on at
    RE: Adding a Button to a Form

    Yes Ravi, already tried all of them and tried on a different comupter as well. Same issue .

  • RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Adding a Button to a Form

    Can you try form refresh? Or in  private/ incognito mode.

  • Dineth Profile Picture
    Dineth on at
    RE: Adding a Button to a Form

    No luck Ravi I tried on second place and top of the list. Same error.

    lib.png

  • RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Adding a Button to a Form

    Move it up...before your custom library

  • Dineth Profile Picture
    Dineth on at
    RE: Adding a Button to a Form

    HI Ravi,

    I already add that 

    3162.processjs.png

  • RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Adding a Button to a Form

    Hi,

    You need to add the process.js web resource as well on the form.

  • Dineth Profile Picture
    Dineth on at
    RE: Adding a Button to a Form

    HI Ravi,

    I have added the complete Zip file and then published and attached the process.js file to form library.

    When I click on the button I m getting this error, I won't get the Workflow executed successfully alert.

    3583.solution.png

    3583.solution.png

  • RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: Adding a Button to a Form

    The complete zip file you downloaded from the site.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans