Fixing SharePoint designer 2013 workflow that won't switch to "Text-based designer" view

I recently wrote a big (200+ lines) List workflow in a SharePoint designer 2013. Those of you who have done it know that it becomes hard to maintain the workflow of this size as SPD is not really designed to author large workflows.

After spending few days, it become common for workflow designer to display validation errors every now and then which happened because SPD kept mysteriously deleting the variable references from the workflow actions.

Finally, i reached the stage where my workflow will not open in text-based designer mode, no matter what i do. It always opened in Visual designer mode with empty visio page.




Exporting the workflow as vsdx file and re-importing as new workflow didn't solve the problem.

After some experimentation, i was able to recover my workflow using the following procedure.

  1. I exported the original workflow as vsdx file using export to visio function. 
  2. I deleted the workflow from SharePoint designer
  3. In SharePoint designer, I created a new workflow “temp” and associated with my original SharePoint List.
  4. New workflow had only 1 line which was logging to history list. I published the workflow
  5. On my computer, I renamed the .vsdx file (step 1) to .zip and extracted all its contents.
  6. In SharePoint designer, I went to navigation windows on left hand side, there i clicked All Files -> WfSvc1 (this is a known folder where SPD stores workflow files)
  7. In that folder, there were many sub-folders, each having a guid as its name. each folder represents a workflow
  8. Went inside each folder and picked the folder which has most recent last modified date for workflow.xaml file (this represents workflow created in step 1)
  9. From the extracted folder (step 5) I copy pasted the file workflow.xaml to the SPD folder (step 8)
  10. Restarted SharePoint designer
  11. Opened the workflow designer page for the new workflow "temp" and it showed the restored workflow J
  12. Renamed & published the workflow

As a lesson learned, i decided to break the workflow into smaller manageable workflow pieces, so that the damage remains minimum in case of future corruption.