locked
Retrieve data from Plugin to Javascript RRS feed

  • Question

  • H i ,

    i need to pass some values from JavaScript  to Plugin. 

    and need to retrieve resultant result from plugin should get invoke in the java script. 

    can anybody guide how to proceed with this approach.

    * please send some sample code & Link , how to invoke plugin from  java script and pass parameter.

    * How to get the resultant from plugin to   java script. 

    Thanks 

    Friday, August 22, 2014 3:31 PM

All replies

  • Can you please explain your real requirement?

    because saying generic passing data between javascript & plugin means nothing in crm


    My blog: www.crmanswers.net - Rockstar 365 Profile

    Friday, August 22, 2014 3:48 PM
  • Hi Guido Preite ,

    I am trying to invoke  retrieve retrieve multiple plugin result in a JavaScript.

    * My plugin fires in retrieve multiple and ill get a collection of records. based on the plugin result , i need to use the result in my java script.

    If i am not still clear , please find the bellow link what exactly my requirement .,

    http://gotchahunter.net/2012/11/dynamics-crm-you-can-call-a-plugin-from-javascript/

    Can you please guide me how to proceed on this.

    Thanks

    Friday, August 22, 2014 4:50 PM
  • Hi Guido Preite ,

    i need to pass some input parameter to the plugin from java-script  . ?

    I need to use the resultant of the plugin entity collection to the javascript ?

    Thanks

    Friday, August 22, 2014 4:58 PM
  • Hi,

    1. Create an empty web resource.

    2. Use your plugin to update the empty web resource with the plugin entity collection by converting it into required format (XML or JSON).

    3. Refer the update web resource in your javascript  to access the content.

    Below is the sample code to update web resource using plugin.

     webResource["name"] = "WEB RESOURCE NAME";
                            webResource["content"] = System.Convert.ToBase64String("PARSE YOUR ENTITY COLLECTION TO XML OR JSON THEN USE HERE");
                            webResource["webresourcetype"] = new OptionSetValue(3);
                            webResourceCollection.Entities.Clear();
                            webResourceCollection.Entities.Add(webResource);

    Register this plugin under Entity - Webresource, Message - Retrievemultiple.


    Thanks and Regards. Mark as answer, if this answers your question.



    • Edited by Ravitheja J Saturday, August 23, 2014 4:32 AM
    • Proposed as answer by Ravitheja J Saturday, August 23, 2014 4:33 AM
    Saturday, August 23, 2014 4:31 AM
  • Hi Ravitheja J ,

    I need to pass some parameter to the plugin using java script.

    Can you please guide how to achieve in this approach.

    as far i searched in goggle , using retrieve multiple message in pre operation we can pass some input parameters.

    similarly , i would also need to pass some parameter from java script to plugin.

    How to invoke my plugin ?

    Thanks


    • Edited by kMAT1 Saturday, August 23, 2014 8:36 AM
    Saturday, August 23, 2014 8:36 AM
  • Hi,

    If your parameters to plugin are static, you could use secure/unsecure config. 


    Thanks and Regards.

    Saturday, August 23, 2014 9:44 AM
  • Hi ,

    not using secured / un secured config.

    i need to achieve it through bellow method.

    gotchahunter.net/2012/11/dynamics-crm-you-can-call-a-plugin-from-javascript/

    can you please provide with sample code & example.

    Saturday, August 23, 2014 11:55 AM
  • Hi,

    Here is the sample code.

     // TODO - Plugin code goes here
    
    Entity webResource = new Entity("webresource");
    // Exract the search criteria 
    QueryBase query = (QueryBase)context.InputParameters["Query"];
    Type queryType = query.GetType();
    if (queryType == typeof(QueryExpression))
    {
    	QueryExpression queryExpression = (QueryExpression)query;
    	if (queryExpression.EntityName != "webresource")
    		return;
    	string webresourceName = (string)queryExpression.Criteria.Conditions[0].Values[0];
       
    		var webResourceCollection = (EntityCollection)context.OutputParameters["BusinessEntityCollection"];
    		var resultBytes = System.Text.Encoding.UTF8.GetBytes("ENTITY COLLECTION RESULT HERE");
    
    		webResource["name"] = "WEB RESOURCE NAME HERE";
    		//UPDATE/APPEND THE CONTENT OF WEB RESOURSE (JAVASCRIPT FILE)
    		webResource["content"] = System.Convert.ToBase64String(resultBytes); 
    		webResource["webresourcetype"] = new OptionSetValue(3);
    		webResourceCollection.Entities.Clear();
    		webResourceCollection.Entities.Add(webResource);
    	}


    Thanks and Regards.


    • Proposed as answer by Ravitheja J Saturday, August 23, 2014 3:25 PM
    • Edited by Ravitheja J Sunday, August 24, 2014 2:19 AM
    Saturday, August 23, 2014 3:25 PM
  • Finally i got a right solution to achieve it by bellow link

    http://gotchahunter.net/2012/11/dynamics-crm-you-can-call-a-plugin-from-javascript/

    Saturday, August 30, 2014 9:21 AM
  • Hey dude, do you have any example of this??? ....the url  doesn't work anymore... 

    Thanks!

     
    Thursday, September 28, 2017 5:42 AM