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 CRM (Archived)

Adding a Button to a Form

(0) ShareShare
ReportReport
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

I have the same question (0)
  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    There are a couple of things that I would check.

    First, on the web resource on the form, make sure that the number of lines for the web resource is one.

    Second, on the web resource, you might want to style the body, so that there is no margins and padding before the button, and possibly set the left/top properties.

    Finally, although the source code that you provided seems like it should work, please verify the source code from the web resource directly to make sure that it matches what you have above. It seems like the web resource might have some extra characters in it.

    Hope this helps.

  • Dineth Profile Picture
    on at

    Thanks Aric, It was the source code, all good now.

    Can I use the following code to execute a workflow when click the button.

    function TestClick()

    {

    alert("clicked!");

    Process.callWorkflow('ADA9DD50-7E6E-4B37-AC1A-86827F0A82C3'>,

      Xrm.Page.data.entity.getId(),

      function () {

          alert("Workflow executed successfully");

      },

      function () {

          alert("Error executing workflow");

      });

    }

  • Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    It seems like you are using Process.js, so that should be fine.

    It looks like you have a > sign after the workflow id that should be removed.

    Besides that it looks good.

    Make sure that you add process.js to the form script libraries.

  • Dineth Profile Picture
    on at

    Hi Aric,

    Could you please tell me how can I add the Process.js to script library. Sorry I m really new to this.

    I have downloaded the solution and ends up with following files.

    files.png

    Could you please guide me what to do next.

    I went through the following link, it says download and installs, sorry I m not 100% sure which file and how to attach this to Dynamics 365. 

    https://github.com/PaulNieuwelaar/processjs/wiki/Documentation

    Thank you very much. 

  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi,

    You need to install that solution in your organisation. Settings >> Solutions >> Import >> {Select the solution file which you downloaded}

    For JavaScript basics, take a look at these blog posts -

    neilparkhurst.com/.../javascript-basics

    dynamicscrmpros.com/getting-started-with-javascript-form-scripting-for-microsoft-dynamics-crm-2011

    Hope this helps

  • Dineth Profile Picture
    on at

    HI Ravi,

    I hope you meant my solution is solution.xml ?

    Thanks.

  • RaviKashyap Profile Picture
    55,410 Moderator on at

    The complete zip file you downloaded from the site.

  • Dineth Profile Picture
    on at

    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
    55,410 Moderator on at

    Hi,

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

  • Dineth Profile Picture
    on at

    HI Ravi,

    I already add that 

    3162.processjs.png

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 CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans