Notifications
Announcements
No record found.
Guys,
I want to call a stored procedure from CRM plugin.
Please let me know whether it is possible or not ..
Or do I need to find another approach to fetch data?
*This post is locked for comments
Hi,
You should create web service.Within that web service you can execute stored procedure.
You can refer below links to get an idea.
community.dynamics.com/.../159599
stackoverflow.com/.../best-approach-to-execute-stored-procedures-from-within-crm-using-a-custom-button
Mansoor
Hi Vinit,
Using Stored procedure is not a recommended way in CRM.
If your requirement is just to fetch simple data then you can use any of the following method.
1. using javascript with SOAP/REST call.
2. using Linq/FetchXML/QueryExpression in plugin/custom workflow.
If above methods are not working in your case and you have no other option rather than using SP then you can follow the below steps.
1. Create a SP in SQL
2. Create a function in plugin/CustomWorkflow to call this SP.
---Code to call SP----
var sProc = "StoredProcedureName";
using (var connection = new SqlConnection(SqlDatabase.GetCustomConnectionString(OrganizationName)))
using (var command = new SqlCommand(sProc, connection))
{
command.Parameters.Add("@InputparameterInSP", SqlDbType.UniqueIdentifier).Value = SendValueTOInputParameter;
command.CommandType = CommandType.StoredProcedure;
command.CommandTimeout = SqlCmdTimeOut;
SqlDataAdapter adapter = new SqlDataAdapter(command);
DataTable results = new DataTable();
adapter.Fill(results);
if (results.Rows.Count > 0)
return results;
}
return null;
Hope this resolve your requirement...
Regards,
Jayesh
Thanks for reply Jayesh,
It's not possible to use JavaScript or linq in this issue because these methods are not able to fetch more than 5000 records.
That's why someone recommend me to use stored procedure.
Anyways... Your answer worked out for me..
Thanks a lot...
Fetching 5000 is your problem then you can achieve it through retrievemultiple() method also in QueryExpression.
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
SA-08121319-0 4
Calum MacFarlane 4
Alex Fun Wei Jie 2