Answered by:
Ribbon button to create a contact

Question
-
I have a ribbon button on lead form... on click of this ribbon button i want to set a two-option set field value to yes (by default it is no)..
Once this field is set to yes.. then i want to create a contact with same name as of the lead name... I want to know how this plugin should be done
Thursday, May 22, 2014 4:35 AM
Answers
-
Hi,
You could use Ribbon Workbench or other similar solutions to add a button to the ribbon. For your button you have to define a JavaScript function to change the optionset value. Have a look at this reference for getting and setting value of the optionsets and two options.
After JS, you could create a plugin and register it on the update message of the lead. The logic for creating such plugin is simple. Have a look at this reference on creating a basic plugin. You could also install the developer toolkit (look at SDK) for VS to facilitate the plugin writing process.
- Marked as answer by Amy.4 Thursday, May 22, 2014 10:45 AM
Thursday, May 22, 2014 5:17 AMModerator -
Hi there Its a very simple plugin.
Just start by getting your contextdata.
Entity eLead = (Entity)context.InputParameters["Target"];- Bare in mind if you dont Update the Lead Name this field wont be in the context and you will need to retrieve it,
Then You need to create an Object of the Entity Contact,
Entity eContact = new Entity("contact");Then you need to populate the the Object with the fields you need.
eContact["name"]= eLead("YOUR_INFORMATION");At the end use your service to create teh Object on CRM.
service.Create(eContact);
- Marked as answer by Amy.4 Thursday, May 22, 2014 10:45 AM
Thursday, May 22, 2014 8:23 AM
All replies
-
Hi,
You could use Ribbon Workbench or other similar solutions to add a button to the ribbon. For your button you have to define a JavaScript function to change the optionset value. Have a look at this reference for getting and setting value of the optionsets and two options.
After JS, you could create a plugin and register it on the update message of the lead. The logic for creating such plugin is simple. Have a look at this reference on creating a basic plugin. You could also install the developer toolkit (look at SDK) for VS to facilitate the plugin writing process.
- Marked as answer by Amy.4 Thursday, May 22, 2014 10:45 AM
Thursday, May 22, 2014 5:17 AMModerator -
Thanks for the reply... i have kept a ribBon button on lead form...
But issue is that i want to change the optionset field value on click of ribbon button..
Thursday, May 22, 2014 5:44 AM -
So, have a look at my second reference.Thursday, May 22, 2014 6:10 AMModerator
-
I am using post image to retrieve the name field of lead and create contact with same name... Can this be done using Formatted Values property.. Can u help me with that syntaxThursday, May 22, 2014 6:33 AM
-
Hi there Its a very simple plugin.
Just start by getting your contextdata.
Entity eLead = (Entity)context.InputParameters["Target"];- Bare in mind if you dont Update the Lead Name this field wont be in the context and you will need to retrieve it,
Then You need to create an Object of the Entity Contact,
Entity eContact = new Entity("contact");Then you need to populate the the Object with the fields you need.
eContact["name"]= eLead("YOUR_INFORMATION");At the end use your service to create teh Object on CRM.
service.Create(eContact);
- Marked as answer by Amy.4 Thursday, May 22, 2014 10:45 AM
Thursday, May 22, 2014 8:23 AM