web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
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

I have the same question (0)
  • Suggested answer
    Guido Preite Profile Picture
    54,086 Moderator on at

    There is no way to extend the 2 minutes timeout inside online instances.

    You need to rewrite your activity to take shorter than 2 minutes or move the logic to an external server (like Azure)

  • Suggested answer
    Venkatesh Nadar Profile Picture
    on at

    Hi,

    The 2minutes Timeout is standard for workflow and plugin in Dynamics 365 CRM. However, you are making external call from workflow if I understood it right?

    Here are some best practices for it-

    Set Timeout when making external calls in a plug-in - Power Apps | Microsoft Docs

    Best practices and guidance when coding for Microsoft Dataverse - Power Apps | Microsoft Docs

    Hope this helps!

    Regards.

    Venkatesh N

  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator on at

    Hello,

    2-minute Timeout setting for Plugin and Custom workflow can not be increased.

    You will need to recheck your workflow logic to minimize the service calls, Also check if you can remove attributes from your service calls which are not required.

    Combine multiple service calls in one service call by using link entities concept.

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

  • Nafas Profile Picture
    160 on at

    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.

  • Suggested answer
    Mahendar Pal Profile Picture
    45,095 on at

    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
    160 on at

       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

           }

       }

  • Nafas Profile Picture
    160 on at

    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.

  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator on at

    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/

  • Katehuston Profile Picture
    15 on at

    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.

  • Community Member Profile Picture
    on at

    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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 72 Super User 2025 Season 2

#2
Daniyal Khaleel Profile Picture

Daniyal Khaleel 32 Most Valuable Professional

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 29 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans