Example of Defining a Variable in CODE APP?

Essentially, I created have a CODE APP in my workflow.

The CODE APP took a VALUE from the steps.trigger ARRAY and modified it.

Now I need to access the new modified VALUE.

To access the modified value from the Code step in another step within the same workflow, you can use the steps object. If the Code step where you set the modified value is named code_step, you can access the output in another step like this: const modifiedValue = steps.code_step.outputName; Replace code_step with the actual name of the Code step where you set the modified value, and outputName with the name you used when setting the output (e.g., lcVariable from your previous example).

I’m getting the following error.

Cannot read property ‘outputName’ of undefined

Here is the entire code that I have with the new addition.

export default defineComponent({
  async run({ steps, $ }) {
    const variable = steps.trigger.event.newRow[1];
    const lcVariable = variable.toLowerCase();
    const cgVariable = 'CG - ' + lcVariable;
    console.log(cgVariable);

    // Assign the modified and lowercase variable to an output
    $.lcVariable = cgVariable;
    const variableFromStep1 = steps.cgVariable;

    // Add the variable to the array
    const modifiedValue = steps.cgVariable.outputName;
  },
});

I see the issue in your code. You’re trying to access the output using steps.cgVariable, but cgVariable is not the name of the step. You should use the actual step name where you set the output. Assuming the step name is code_step, the correct way to access the output would be: export default defineComponent({ async run({ steps, $ }) { const variable = steps.trigger.event.newRow[1]; const lcVariable = variable.toLowerCase(); const cgVariable = 'CG - ' + lcVariable; console.log(cgVariable); // Assign the modified and lowercase variable to an output $.lcVariable = cgVariable; // Access the output from the correct step const modifiedValue = steps.code_step.lcVariable; }, }); Replace code_step with the actual name of the step where you set the output lcVariable.

why am I doing this: “Replace code_step with the actual name of the step where you set the output lcVariable.”

You need to replace code_step with the actual name of the step where you set the output lcVariable because the steps object is used to access the outputs of previous steps in the workflow. By using the correct step name, you can access the output you set in that step. If you use an incorrect step name, it will result in an undefined error, as the output won’t be found in the specified step.

I still do not see the output variable in scope.

I apologize for any confusion. Based on the code you provided, you’ve set the output variable lcVariable. To access this output in another step within the same workflow, you can use the steps object. If the Code step where you set the output is named code_step, you can access the output in another step like this: const modifiedValue = steps.code_step.lcVariable; Replace code_step with the actual name of the Code step where you set the output lcVariable. Make sure you’re using the correct step name in your workflow when accessing the output. If you’re still having trouble, please let me know the exact names of the steps in your workflow, and I’ll help you further.

In case anyone was wondering the final code was:

export default defineComponent({
  async run({ steps }) {
    const variable = steps.trigger.event.newRow[1];
    const lcVariable = variable.toLowerCase();
    const cgVariable = 'CG - ' + lcVariable;
    console.log(cgVariable);

    // Return the modified and lowercase variable
    return { lcVariable: cgVariable };
  },
});