Hi everyone!
I m new in plugin development. I have followed some guidance by Microsoft and a sample script but i need guidance on how to create a plugin to count the service activities every 15 days.
Now the code i used using javascript is the one below , but i need to create a plugin to make that concurrent workflow :
var fetchXml = "<fetch version='1.0' aggregate='true' >" + "<entity name='serviceappointment' >" + "<filter type='and' >" + "<condition attribute='scheduledstart' operator='next-month' />" + "</filter>" + "<attribute name='activityid' alias='count' aggregate='count' />" + "</entity>" + "</fetch>" ; /*"<fetch mapping='logical' aggregate='true'>" + "<entity name='account'>" + "<attribute name='accountid' aggregate='count' alias='count' />" + "</fetch>";*/ var result = XrmServiceToolkit.Soap.Fetch(fetchXml, false); if((result) && (result.length) && (result.length > 0)) { var count = result[0].attributes['count'].value; } // Something is wrong return -1; }
So i found this code on Microsoft :
// ***************************************************************************************************************** // FetchXML opportunity_count Aggregate 2 // ***************************************************************************************************************** // Fetch the count of all opportunities. This is the equivalent of // SELECT COUNT(*) AS opportunity_count ... in SQL. string opportunity_count = @" <fetch distinct='false' mapping='logical' aggregate='true'> <entity name='opportunity'> <attribute name='name' alias='opportunity_count' aggregate='count'/> </entity> </fetch>"; EntityCollection opportunity_count_result = _serviceProxy.RetrieveMultiple(new FetchExpression(opportunity_count)); foreach (var c in opportunity_count_result.Entities) { Int32 aggregate2 = (Int32)((AliasedValue)c["opportunity_count"]).Value; System.Console.WriteLine("Count of all opportunities: " + aggregate2); } System.Console.WriteLine("===============================");
Shouldn't i get run the exectute function like in one of the sample plugins i read ? Also where this workflow should run , i don't want it to run on record creation or update. I just want it to run globally every 15 days and target Service Activities through the fetchxml. And how a custom workflow activity can be executed every 15 days?
Thanks a lot and sorry for the noobish questions!
*This post is locked for comments