Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

Increase execution time from 2 minutes

(0) ShareShare
ReportReport
Posted on by 160

Hi. I have a custom workflow in c# code and call it from workflow in CRM. workflow raise an error as show below in attached image. Has anyone solution for that? I have to say we are using CRM online.

pastedimage1641288007998v1.png

  • Suggested answer
    furkank Profile Picture
    furkank 535 on at
    RE: Increase execution time from 2 minutes

    Hi, If you are using Dynamics 365 Online, why don't you just use Power Automate? There is no time limit in Power Automate flows. Increasing workflow execution time limit won't solve your issue, it will stress your environment resources more!

  • Suggested answer
    Abdul Wahab Profile Picture
    Abdul Wahab 12,070 Super User 2024 Season 1 on at
    RE: Increase execution time from 2 minutes

    Hi Golnaz Najafdari,

    Do one thing. Do not parse the whole response at once. Run the workflow recursively. Each time parse records which the system can parse in 2 minutes like 10 responses, or 20 responses... Whatever but in 2 minutes. Further, you must have a mechanism through which you are having new records on each call... If this is the only option for you.

    You can use 'Power Automate' with custom connectors if the connector is not available already.

    You can create a console application and run it using a window scheduler. Here you do not have a 2-minute limit but you required a mechanism through which you are having new records on each call.

  • davewhite Profile Picture
    davewhite 5 on at
    RE: Increase execution time from 2 minutes

    I recommend you to hire a dedicated developer to fix this issue fast. Here's the tutorial: https://jaydevs.com/dedicated-software-development-teams/

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Increase execution time from 2 minutes

    There is the no way to increase the time but you need to write program in such a way that program will execute within 2 minutes.

    juniorcrmblog.blogspot.com/.../ms-dynamic-crm-interview-question-for-2.html

  • Katehuston Profile Picture
    Katehuston 15 on at
    RE: Increase execution time from 2 minutes

    A quality app development company https://mlsdev.com/blog/healthcare-mobile-app-development should perform comprehensive market research before starting any project. A detailed market analysis report will provide a comprehensive analysis of your target audience. It will also study other similar apps in the marketplace, as well as identify possible dos and don'ts. It should also be able to provide an accurate budget, expected time of delivery, and comprehensive resource list. It should have the ability to quickly and efficiently meet your specific needs.

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: Increase execution time from 2 minutes

    Hello,

    I see you are retrieving all columns from Dynamics crm -

    _query.ColumnSet = new ColumnSet(true);

    why do we need to do that?

    This will impact your performance, so my recommendation is to update your code to select columns which you need instead of retrieving all columns.

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

  • Nafas Profile Picture
    Nafas 160 on at
    RE: Increase execution time from 2 minutes

    I write this code that call an api for mail and get list of mailing and loop for it to find specific contact to update.

  • Nafas Profile Picture
    Nafas 160 on at
    RE: Increase execution time from 2 minutes

       public class Mailing : CodeActivity

       {

           [Input("Customer")]

           [ReferenceTarget("contact")]

           public InArgument<EntityReference> Customer { get; set; }

           protected override void Execute(CodeActivityContext executionContext)

           {

               IWorkflowContext context = executionContext.GetExtension<IWorkflowContext>();

               IOrganizationServiceFactory serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();

               IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);

               try

               {

                   var _pageMailing = 1;

                   FilterExpression filter = new FilterExpression();

                   //filter.Conditions.Add(new ConditionExpression("tch_created", ConditionOperator.Equal, "Today"));

                   QueryExpression _query = new QueryExpression("hup_mailids");

                   _query.ColumnSet = new ColumnSet(true);

                   _query.Criteria = filter;

                   EntityCollection List = service.RetrieveMultiple(_query);

                   for (int m = 0; m < List.Entities.Count; m++)

                   {

                       string url = "apiv3.emailsys.net/.../" + List.Entities[m]["hup_name"] + "/stats/activity?&page=" + _pageMailing;

                       JObject joResponseMailing = JObject.Parse(_request.Request(url));

                       JObject ojObjectMailing = (JObject)joResponseMailing["_embedded"];

                       JArray arrayMailing = (JArray)ojObjectMailing["mailingrecipients"];

                       int page_countMailing = (int)joResponseMailing["page_count"];

                       for (int k = 0; k < arrayMailing.Count; k++)

                       {

                           var CustomerEmail = (string)arrayMailing[k]["email"];

                           QueryExpression _query2 = new QueryExpression("contact");

                           _query2.ColumnSet = new ColumnSet(true);

                           FilterExpression filter2 = new FilterExpression();

                           filter2.Conditions.Add(new ConditionExpression("emailaddress1", ConditionOperator.Equal, CustomerEmail));

                           _query2.Criteria = filter;

                           EntityCollection List2 = service.RetrieveMultiple(_query2);

                           if (List2.Entities.Count > 0)

                           {

                               var rapidMailAddress = "my.rapidmail.de/.../show.html + List.Entities[m]["hup_name"];

                               List2.Entities[k]["hup_rapidmailaddress"] = rapidMailAddress;

                               service.Update(List2.Entities[k]);

                           }

                       }

                       for (int p = 2; p < page_countMailing; p++)

                       {

                           url = "apiv3.emailsys.net/.../" + List.Entities[m]["hup_name"] + "/stats/activity?&page=" + p;

                           JObject joResponseMailing2 = JObject.Parse(_request.Request(url));

                           JObject ojObjectMailing2 = (JObject)joResponseMailing2["_embedded"];

                           JArray arrayMailing2 = (JArray)ojObjectMailing2["mailingrecipients"];

                           int page_countMailing2 = (int)joResponseMailing2["page_count"];

                           for (int n = 0; n < arrayMailing2.Count; n++)

                           {

                               var CustomerEmail2 = (string)arrayMailing2[n]["email"];

                               QueryExpression _query3 = new QueryExpression("contact");

                               _query3.ColumnSet = new ColumnSet(true);

                               FilterExpression filter3 = new FilterExpression();

                               filter3.Conditions.Add(new ConditionExpression("emailaddress1", ConditionOperator.Equal, CustomerEmail2));

                               _query3.Criteria = filter3;

                               EntityCollection List3 = service.RetrieveMultiple(_query3);

                               if (List3.Entities.Count > 0)

                               {

                                   var rapidMailAddress2 = "my.rapidmail.de/.../show.html + List.Entities[m]["hup_name"];

                                   List3.Entities[n]["hup_rapidmailaddress"] = rapidMailAddress2;

                                   service.Update(List3.Entities[n]);

                               }

                           }

                       }

                   }

               }

               catch (Exception ex)

               {

                   new Exception("Error:" + ex.Message);

                   throw;

               }

           }

       }

       class _request

       {

           public static string Request(string _url)

           {

               #region Request

               string username = "fdaa101384d00c86767367d575d99184be431950";

               string password = "fb0cf7ca6628b474ca632fec5e483ebdc70944a2";

               byte[] auth = Encoding.ASCII.GetBytes(username + ":" + password);

               string encodedAuth = Convert.ToBase64String(auth);

               HttpWebRequest request = (HttpWebRequest)WebRequest.Create(string.Format(_url));

               request.Method = "GET";

               request.ContentType = "application/hal+json";

               request.Headers.Add("Authorization", "Basic " + encodedAuth);

               request.Accept = "*/*";

               WebResponse webResponse = request.GetResponse();

               Stream webStream = webResponse.GetResponseStream();

               StreamReader responseReader = new StreamReader(webStream);

               string response = responseReader.ReadToEnd();

               return response;

               #endregion

           }

       }

  • Suggested answer
    Mahendar Pal Profile Picture
    Mahendar Pal 45,095 on at
    RE: Increase execution time from 2 minutes

    Hi,

    I will suggest you to look for the Azure plugin, you can implement your logic in Azure using different options:

    Writing Azure aware plugin

    docs.microsoft.com/.../write-custom-azure-aware-plugin

    Using Azure Webhook ( you can write your logic on the Azure http function and can call it from Azure web hook

    docs.microsoft.com/.../use-webhooks

    Keep in mind Azure function have different plan if your logic can be completed within 10 min you can use consumption plan but it's going to take more then that, you have to go to premium plan.

    docs.microsoft.com/.../functions-scale

  • Nafas Profile Picture
    Nafas 160 on at
    RE: Increase execution time from 2 minutes

    I call an external api in my code and have to request to this api many times in my code and check the result in loop. because the result is too huge, checking is too long. I think I can't reduce this logic anymore.

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.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans