Answered by:
crm 2011: how to trigger plugin from ribbon custom button's javascript?

Question
-
Hi,
i have email plugin which is fire on update after click on save button and i did ribbon button that call javascript
now logic is on ribbon custom button click then call email plugin
now i am calling hidden field in javascript to update hidden field
but how to fire update plugin on ribbon button without click on form save button??
Ashish
- Edited by Ashish Sharma Engg Friday, March 23, 2012 10:28 AM
Friday, March 23, 2012 10:27 AM
Answers
-
Thanks all,
now it is working
from ribbon custom button JavaScript to handle plugin when it will trigger...
Ashish
- Marked as answer by Ashish Sharma Engg Monday, March 26, 2012 9:35 AM
Monday, March 26, 2012 9:34 AM
All replies
-
Hi Ashish,
Have a look at this Blog, it should address your question.
http://code.msdn.microsoft.com/windowsdesktop/Trigger-a-Plug-in-in-75699228
Eric UNG [Senior Analyst Programmer :: Sydney, Australia]
Friday, March 23, 2012 10:45 AM -
Hi Ashish,
Your plugin is registered on the update message of the entity. Now you are calling JavaScript from Ribbon button. In this JavaScript you are trying to update a form field. Now when you 'save' the form from inside JavaScript or 'save and close' this form from inside JavaScript, the update plugin will fire.
In CRM 2011 according to the new JavaScript model, the save command to save the entity is: Xrm.Page.data.entity.save(); This is same as SAVE button on entity form, but you are not clicking the button.
The save and close command is: Xrm.Page.data.entity.save('saveandclose'); This is same as SAVE AND CLOSE button on entity form, but again you are not clicking the button.
I hope this helps. If my response answered your question, please take a minute and mark the response as an answer.
Ashish Mahajan, CRM Developer, CSG (Melbourne)
My Personal Website: http://www.ashishmahajan.com
My Blogs: http://ashishmahajancrm.blogspot.com.au and http://ashishmahajancrm.wordpress.com
My Youtube Channel: http://www.youtube.com/user/ashishmahajanmscrmMy Linkedin: Friday, March 23, 2012 11:06 AM -
Thanks Ashish for code
Xrm.Page.data.entity.save(); but i want to use this for ribbon button javascript when i call this it may work but it also work when user clieck on form save button
i need to trigger update mail plugin when only on ribbon button javascript ?? not when form save button...
Ashish
- Edited by Ashish Sharma Engg Friday, March 23, 2012 12:36 PM
Friday, March 23, 2012 12:35 PM -
Thanks Eric but this blog has files which i am not clear...
Ashish
Friday, March 23, 2012 12:50 PM -
Hi Ashish,
If you have a plugin registered on an entity update message, yes, you are right it will fire.
I suggest, you call web services/oData in your JavaScript and try executing the functionality instead of your email plugin. You can try executing your functionality from within JavaScript rather than a Plugin.
Ashish Mahajan, CRM Developer, CSG (Melbourne)
My Personal Website: http://www.ashishmahajan.com
My Blogs: http://ashishmahajancrm.blogspot.com.au and http://ashishmahajancrm.wordpress.com
My Youtube Channel: http://www.youtube.com/user/ashishmahajanmscrmMy Linkedin: - Proposed as answer by Ashish Mahajan Technical Architect, Writer Friday, March 23, 2012 1:31 PM
Friday, March 23, 2012 1:30 PM -
Hi Ashish,
You could fire an ondemand workflow on click of your button. That can then either send your email, or set a value on your form to trigger the plugin. Because the workflow would run asynchronously, you wouldn't need to save your form for it to execute.
There are plenty of articles around calling workflows from javascript, here is one example:
http://nishantrana.wordpress.com/2011/04/26/calling-on-demand-workflow-through-a-button-in-ribbon-launchondemandworkflow-in-crm-2011/Hope that helps.
-Paul
Friday, March 23, 2012 1:46 PM -
Thanks all,
now it is working
from ribbon custom button JavaScript to handle plugin when it will trigger...
Ashish
- Marked as answer by Ashish Sharma Engg Monday, March 26, 2012 9:35 AM
Monday, March 26, 2012 9:34 AM -
Hai,
Could you please let me know how did you do this?? I'm also insearch of same criteria?
Regards
Sravani
Monday, October 8, 2012 9:10 AM