Hi,
I have requiremnet to call plugin when clik on Iframe button in CRM 365 online.
What will be the best approach to achieve this functionaliy.
It will be great if provide any links or sample code.
Thanks,
*This post is locked for comments
Hi,
I have requiremnet to call plugin when clik on Iframe button in CRM 365 online.
What will be the best approach to achieve this functionaliy.
It will be great if provide any links or sample code.
Thanks,
*This post is locked for comments
Hi,
Thanks to Goutam and Shaminderpal for your solutions.
Hi Shaminder,
Can you please share the code for these components, that will really helpful for me.
If possible you can share the code to my id
naveenmscrm@yahoo.com
Thanks,
Hi Naveen,
You can achieve this by following steps:
1)Create an action in CRM of Global Type
2)Create an input parameter for that action
3)Write a plugin on action
4)Call your external api's in plugin
5)Serialize api result in json
6)Return result as output param from action
7)Invoke action from js,which will invoke plugin
8)Display result in html
Have done the similar thing in one of my previous projects.
Let me know if you need any help in code for this.
Regards,
Shaminder
Hi Naveen ,
My earlier comment Step 1 step step 6 , I have mentioned how to pass text parameter .
For result once you get the result from third party inside , I don't know how many records it can be just create another temporary entity and insert there .
From client side you just retrieve in some time spent and show in the HTML.
Hope this helps.
Hi Goutam,
Thanks for your solution.
As per my requirement, once we read serach text from custom entity will pass that as input parameter for external web service through plugin.
Once get the results showing in html table for end user view.
Please let me know if that make sense.
Thanks,
Hi Naveen,
Here is the step you can follow -
1- Create dummy Entity lets say CustomSearch.
2- Create One Record with Name = "Dummy Search Text" in that entity.
3- Register your plugin either pre-operation or post-operation and messages will be update operation.
4- From Javascript Web API update the Name field of the dummy created record with your Search Text value.
5- You may maintain the dummy GUID in somewhere in the Configuration entity for every time update same record with search Text.
6- In the plugin you always get the searchText value from Update entity information to call external API.
Now questions is how could you get the result but through plugin its difficult until you are not saving the data to another entity and then retrieve using Web API from that entity.
Normally In on premise environment what I did in this scenario we are calling a wrapper REST WCF service to call the third party SOAP service and from client side we are just calling the internal REST WCF service to get the data from third party service .
Hope this helps .
Hi Naveen,
Here is the step you may follow -
1- Create dummy Entity lets say CustomSearch.
2- Create One Record with Name = "Dummy Search Text" in that entity.
3- Register your plugin either pre-operation or post-operation and messages will be update operation.
4- From Javascript Web API update the Name field of the dummy created record with your Search Text value.
5- You may maintain the dummy GUID in somewhere in the Configuration entity for every time update same record with search Text.
6- In the plugin you always get the searchText value from Update entity information to call external API.
Now question is how could you get the result but through plugin its difficult until you are not saving the data to another entity and then retrieve using Web API from that entity.
Normally In on premise environment what I did in this scenario we are calling a wrapper REST WCF service to call the third party SOAP service and from client side we are just calling the internal REST WCF service to get the data from third party service .
Hope this helps .
Hi All,
Thanks for your reply.
Gautam,
As per my requirement I will have textbox and Search buttion in Iframe.
When I click on this button I need to pass textbox value to plugin and In plugin code I am calling external API to get results.
Please let me know if need any other information.
Thanks,
Hi Naveen ,
In which entity event your plugin has been registered?
Are you creating or updating something when you are clicking on the Iframe button ? You may know in that case the plugin will trigger automatically.
If you are not doing any operation on the entity which you have registered your plugin , then I would suggest create a dummy entity and registered your plugin there and trigger on that entity messages. Like create dummy entity data or update dummy entity data and trigger your plugin.
There is many way you can trigger create and update operation on dummy entity using javascript through WEB API .
Here is one reference you can check -
community.dynamics.com/.../how-to-trigger-a-plug-in-from-jscript-in-microsoft-dynamics-crm
Below is the java script code that you can use
function CallActionFromJavaScript() {
var accountId = Xrm.Page.data.entity.getId();
var entityName = "account";
var requestName = "new_Plugin_process";
ExecuteAction(accountId, entityName, requestName);
}
function ExecuteAction(entityId, entityName, requestName) {
// Creating the request XML for calling the Action
var requestXML = ""
requestXML += "<s:Envelope xmlns:s=\"schemas.xmlsoap.org/.../envelope\">";
requestXML += " <s:Body>";
requestXML += " <Execute xmlns=\"schemas.microsoft.com/.../Services\" xmlns:i=\"www.w3.org/.../XMLSchema-instance\">";
requestXML += " <request xmlns:a=\"schemas.microsoft.com/.../Contracts\">";
requestXML += " <a:Parameters xmlns:b=\"schemas.datacontract.org/.../System.Collections.Generic\">";
requestXML += " <a:KeyValuePairOfstringanyType>";
requestXML += " <b:key>Target</b:key>";
requestXML += " <b:value i:type=\"a:EntityReference\">";
requestXML += " <a:Id>" + entityId + "</a:Id>";
requestXML += " <a:LogicalName>" + entityName + "</a:LogicalName>";
requestXML += " <a:Name i:nil=\"true\" />";
requestXML += " </b:value>";
requestXML += " </a:KeyValuePairOfstringanyType>";
requestXML += " </a:Parameters>";
requestXML += " <a:RequestId i:nil=\"true\" />";
requestXML += " <a:RequestName>" + requestName + "</a:RequestName>";
requestXML += " </request>";
requestXML += " </Execute>";
requestXML += " </s:Body>";
requestXML += "</s:Envelope>";
var req = new XMLHttpRequest();
req.open("POST", Xrm.Page.context.getClientUrl() + "/XRMServices/2011/Organization.svc/web", false);
req.setRequestHeader("Accept", "application/xml, text/xml, */*");
req.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
req.setRequestHeader("SOAPAction", "schemas.microsoft.com/.../Execute");
req.send(requestXML);
//Get the Resonse from the CRM Execute method
var response = req.responseXML;
alert("Saved successfully");
}
This is action = "new_Plugin_process" which i am calling from javascript
Thanks,
Shahbaaz
Hi Naveen,
You can trigger action from your javascript when you open Iframe, that action will create a custom message in Plugin registration tool, using that messgae you can call plugin.
Please check below link,
community.dynamics.com/.../how-to-trigger-a-plug-in-from-jscript-in-microsoft-dynamics-crm
debajmecrm.com/.../dynamics-crm-plugin-javascript-client-script
Please mark as verified if it helps you.
Best regards,
Shahbaaz
Mohamed Amine Mahmoudi
83
Super User 2025 Season 1
Community Member
52
dkrishna
6