locked
Pass data from javascript to plugin RRS feed

  • Question

  • Dear Forum,

     

    how i am able to pass data from a form script (JScript) into a plugin ?

     

    -> About any kind of Service Endpoint ?  (I read something about this)

    ->Trigger plugin from script ?

     

    Greets,

    Jan


    • Edited by Jan1992 Friday, October 7, 2011 1:29 PM
    Friday, October 7, 2011 1:28 PM

Answers

  • Hello Jan,

    I think you can do that by adding a new field to the form and makes it hidden, from javascript you just fill this field with the data you need to pass to your plugin , so on save which could be update or create message, read this field from the plugin and that's it.


    Osama
    • Marked as answer by Jan1992 Tuesday, October 11, 2011 10:07 AM
    Tuesday, October 11, 2011 7:56 AM

All replies

  • You can trigger a plugin from script if you do something in the script like update an entity or something that fires a platform message.  What you could do is create a custom entity to act as a trigger and also as a repository to hold your parameters.  Create or update it using jscript and , if you have a plugin attached to the message, it will fire and will be able to access the data on that custom trigger entity that could be your parameters you need to pass.

     

    Does this make sense?  It makes sense in my head but the way things translate from thought to written word don't always work so well.  :)  If you have questions let me know.


    Jamie Miley
    Check out my about.me profile!
    http://mileyja.blogspot.com
    Linked-In Profile
    Follow Me on Twitter!
    Friday, October 7, 2011 3:59 PM
    Moderator
  • Hi Jamie

     

    First of all, thanks for tanking time to reply.

     

    I've already tried the way of using JScript for creating coentity wich fires plugin. I used this example: http://www.bizforward.cws-international.com/2011/01/26/creating-records-in-crm-2011-using-javascript/

     

    But I don't get really fimliar with this code, because I havn't got much Jscript experience at the moment.

     

    Are the any other ways with a technique called 'servicepoints' ?

     

    Greetings, Jan

    Monday, October 10, 2011 6:04 AM
  • No, service endpoints are for Azure appfabric integration.  Here are some more jscript examples from my blog on creating and updating records.

     

    See if these help

    Also, http://crm2011soap.codeplex.com/  here is a good tool i created that will help you covert c# calls made through the soap logger solution in the SDK to jscript.


    Jamie Miley
    Check out my about.me profile!
    http://mileyja.blogspot.com
    Linked-In Profile
    Follow Me on Twitter!
    Monday, October 10, 2011 2:55 PM
    Moderator
  • Hi,

    You can not fire a plugin form the JavaScript but you can execute a workflow via a JavaScript, plugins are registered on entity events i.e. Create, Update, Delete, Assignment etc. so from JavaScript if you will perform some action then as a result the plugin code will be executed automatically i.e. if you want to invoke Update event of an entity then you can create a new field into the entity and then can update the field via JScript i.e. Xrm.Page.getAttribute("new_two_optionset_field").setValue("true"); and then call Xrm.Page.data.entity.save() method to force form saving.


    Jehanzeb Javeed

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    Monday, October 10, 2011 3:27 PM
  • Yes you can fire a plugin from javascript by the method I specified above, by attaching the plugin to the create or update of a custom entity (to basically be used as a trigger).  Then you can update or create an instance of that entity in jscript.  When you create or update the trigger entity you can also fill it's attributes as a way of passing data to to the plugin.

     


    Jamie Miley
    Check out my about.me profile!
    http://mileyja.blogspot.com
    Linked-In Profile
    Follow Me on Twitter!
    Monday, October 10, 2011 4:13 PM
    Moderator
  • Hello Jan,

    I think you can do that by adding a new field to the form and makes it hidden, from javascript you just fill this field with the data you need to pass to your plugin , so on save which could be update or create message, read this field from the plugin and that's it.


    Osama
    • Marked as answer by Jan1992 Tuesday, October 11, 2011 10:07 AM
    Tuesday, October 11, 2011 7:56 AM
  • Thank you so much for you help guys,

     

    but I decided to get my data about JavaScript using REST Endpoint.

     

    But I'm freaking out with this, SDK sample run, Script does not.

     

    Greetings, Jan.

    Tuesday, October 11, 2011 10:09 AM