WriteToFile

Node Action:

The WriteToFile node action writes data to a file location.

Parameters:

se_type

WriteToFile

se_type = WriteToFile

se_filePath

The file path to write the data.

se_determineFilePath

A lambda to build a file path.

se_determineData

A lambda to build the data string to write out to the file.

Example:

Push to GIS with QAQC: When an assignment is completed a QAQC web page is launched. The workflow writes a file with the component count. Then the workflow waits for a signal from the web page to run QAQC on the count file and return a result. The workflow then transitions to a completed or canceled state based on the web page result.

digraph finite_state_machine { 

  splines=spline; 
  edge[arrowsize=1, color=black];
  node[shape = box, color = green];
  
  entry[
    label = "Push to GIS (only visible if QA/QC needs to run)", 
    shape= invhouse,
    height = 1,
        
    se_type1 = CompleteAssignmentTrigger,
    se_displayName1 = "Push to GIS (QA/QC needs run)"
    se_iconUrl1 = ""
    se_requiresConfirmation1 = false,
    se_requiresInternet1 = false,
    se_sortOrder1 = 10,
    se_visibilityCondition1 = "function (ctx, msLogger){
      return ctx.Event.design.customProperties.designStatus != \"QA/QC ran successfully\" && ctx.Event.assignment.assignmentType == \"Draw\";
    }",
    
    se_type2 = Action,
    se_action2 = "function (ctx, log){
      ctx.State.WorkflowButtonKey = \"SendForApproval\";
    }"
    
    
    se_type3 = GetDesignStateResource,
    se_determineAssignmentId3 = "function (ctx, msLogger){
      return `${ctx.Event.assignment.id}`;
    }",
    se_resultVariable3 = Dsr
  ]; 
  
  runQaQc[
    label = "Run QA/QC"
    
    se_type1 = WriteToFile,
    se_determineData1 = "function (ctx, msLogger){
       return `${ctx.State.Dsr.components.length}`;
    }",
    se_determineFilePath1 = "function (ctx, msLogger){
       return System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments), \"MyDsrComponentCount.json\");
    }",
    
    se_type2 = LaunchUriScheme,
    se_determineUri2 = "function (ctx, log){
    
      var path = encodeURIComponent(System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments), \"MyDsrComponentCount.json\"));
    
      return `https://kevincloudshellstorage.z22.web.core.windows.net?signalName=FirstSignal&designId=${ctx.Event.design.id}&fileName=${path}`;
    }",
    
    se_type3 = WaitFor,
    se_resultVariable3 = SignalPayload
    se_showBusyDialog3 = true,
    se_signalName3 = "FirstSignal"
  ]
  
  
  exit[
    label = "Complete"
    
    shape=invhouse, 
    color="#22FF44", 
    style=filled
  
    
    se_type1 = Action,
    se_action1 = "function (ctx, log){
      ctx.Output.WorkflowButtonKey = ctx.State.WorkflowButtonKey;
    }"
  ]
  
  cancel[
    label= "Cancelled", 
    shape=invhouse, 
    color=yellow, 
    style=filled
    
    se_type0 = PromptUser,
    se_cardTemplate0 = "{
        \"$schema\": \"http://adaptivecards.io/schemas/adaptive-card.json\",
        \"type\": \"AdaptiveCard\",
        \"version\": \"1.3\",
        \"body\": [
            {
                \"type\": \"TextBlock\",
                \"text\": \"QA/QC has failed or was cancelled. You must complete the QA/QC process before you may complete this assignment.\"
            },
            {
                \"type\": \"ActionSet\",
                \"actions\": [
                    {
                        \"type\": \"Action.Submit\",
                        \"title\": \"Ok\"
                    }
                ]
            }
        ]
    }"

    
    se_type1 = Action,
    se_action1 = "function (ctx, log){
      ctx.Output.Cancel = true;
    }"
  ]
  
  entry->runQaQc[
    weight = 10
    
    
    se_type = Condition
    se_condition = "function (ctx, log){
        return ctx.Event.design.customProperties.designStatus != \"QA/QC ran successfully\";
    }"
  ]
  
  runQaQc->exit[
    xlabel = "QA/QC succeeded"
    weight = 2
    
    se_type = Condition
    se_condition = "function (ctx, log){
      return ctx.State.SignalPayload != null && ctx.State.SignalPayload.success == \"true\";
    }"
  ]
  
  runQaQc->cancel[
    xlabel = "QA/QC failed"
    
    se_type = Condition
    se_condition = "function (ctx, log){
      return ctx.State.SignalPayload == null || ctx.State.SignalPayload.success != \"true\";
    }"
  ]
    
    
    
  
}
Feedback
QR Code is a registered trademark of DENSO WAVE INCORPORATED in Japan and other countries.