SBX - Search With Button

SBX - Forum Post Title

How to run C# code clicking on ribbon button?

Dynamics 365 General Forum

KamalpreetSingh asked a question on 10 Nov 2018 12:46 PM

Question Status

Suggested Answer

I added a button in contact forum ribbon using Ribbon Workbench

There are many components in a solution and I am having hard time figuring out the following-

  • How to create a c# solution that can be published and executed from a button click from ribbon.
  • On clicking button, I should be able to pass some values from contact form such as "Full name", "Company Name", "Email", "Address" etc.
  • Once the C# code finishes its execution, it should present result to user in a pop up.

I understand that its scope is large but all I need to know is someone to guide me to correct resources.

Thanks

Reply
Suggested Answer

Hi KamalpreetSingh,

You can do this by creating an an action and call the action using JavaScript on your custom button. Actions can be called in JavaScript using Web API or Process.CallAction() method in process.js library or SoapLogger.

Check out the below links for more on this.

  1. Call Actions from Javascript/C# in CRM 2013/2015 and Trigger a plugin
  2. Call plugin from Javascript in Microsoft Dynamics CRM
Reply
LeoAlt responded on 11 Nov 2018 8:53 PM
My Badges
Suggested Answer

Hi partner,

You could refer to the steps bellow.

1.Create a plug-in using c# code with your business logic and Register the plugin assembly and step.

2.Create a JavaScript to call plug-in.

3.Use ribbon workbench to relate c# plug-in and JavaScript.

Here is an complete description about how to trigger plug-in by ribbon.

http://www.magnifez.com/execute-a-plugin-from-javascript-in-dynamics-crm/

In addition, if you want to pass parameters to plug-in, you could get the data you need like "Full name", "Company Name" by JavaScript and then pass them to plug-in.

Hope it helps.

Best Regards

Leo

Reply
Suggested Answer

Hi KamalpreetSingh,

You can do this by creating an an action and call the action using JavaScript on your custom button. Actions can be called in JavaScript using Web API or Process.CallAction() method in process.js library or SoapLogger.

Check out the below links for more on this.

  1. Call Actions from Javascript/C# in CRM 2013/2015 and Trigger a plugin
  2. Call plugin from Javascript in Microsoft Dynamics CRM
Reply
LeoAlt responded on 11 Nov 2018 8:53 PM
My Badges
Suggested Answer

Hi partner,

You could refer to the steps bellow.

1.Create a plug-in using c# code with your business logic and Register the plugin assembly and step.

2.Create a JavaScript to call plug-in.

3.Use ribbon workbench to relate c# plug-in and JavaScript.

Here is an complete description about how to trigger plug-in by ribbon.

http://www.magnifez.com/execute-a-plugin-from-javascript-in-dynamics-crm/

In addition, if you want to pass parameters to plug-in, you could get the data you need like "Full name", "Company Name" by JavaScript and then pass them to plug-in.

Hope it helps.

Best Regards

Leo

Reply

SBX - Two Col Forum

SBX - Migrated JS