-1

We have a custom workflow action where the process method can sometimes take a significant amount of time. This causes the browser to hang and sometimes show a browser waiting message.

I am looking for recommendations on how to implement an asynchronous workflow process. I am thinking something like the following:

  1. Custom Workflow Action is triggered
  2. Custom Action triggers asynchronous call to perform processing.
  3. Custom Action moves workflow state to "Processing" state.
  4. Completion of asynchronous call moves workflow state to next state after processing.
  5. A custom workflow button for processing state would run ajax calls in the background checking to see if state has been updated. Once update, it would reload the work flow section. I am not sure how I would accomplish this last block.

Anyone have any recommendations for this kind of flow?

0

It is not possible to reload only a section of an item programmatically without reloading the entire item in the tree. You would need to take into account that the content editor might have moved to another item until the process method completes, in that case you wouldn't need to do a refresh of the item.

You can use one of these commands for refresh:

    string refresh = string.Format("item:refresh(id={0})", youritem.ID);
    Sitecore.Context.ClientPage.ClientResponse.Timer(refresh, 2);

    string load = $"item:load(id={youritem.ID},language={youritem.Language},version={youritem.Version})";
    Sitecore.Context.ClientPage.ClientResponse.Timer(load, 2);

Not sure what the long process method is doing and how much control you would have on the items that are in Processing state, but for points 4/5 you could use an approach similar to how some translation modules are implemented:

  • all items sent for translation are in the Translating state, in your case Processing
  • there is a sitecore job agent which runs every 1-2 minutes <agent type="..." method="Run" interval="00:02:00"/> which checks if the items should be moved to the Final state.

It depends on how fast after the process method completes you need to have the state updated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.