Get Value of Variable stops appending on last call & sets result to only that last variable

applescriptautomationautomatorjavascriptmail.app

I have created a simple workflow in Automator to ask questions & send an email. I followed the tutorial at https://macmost.com/create-customizable-text-inserts-using-automator.html. This has worked for me in different usages, but in this workflow, I have an issue. Near the end of the workflow, multiple variables are retrieved using "Get Value of Variable" to create a message consisting of them all. As each variable is retrieved, it is added to the last variables. However, the last get value of the variable I use deletes all of the other variables which were previously shown in "results" and the result becomes only that variable.

I have attached an image for reference. As you can see it continues to increase (4 items, 5 items), but when the last variable is got, it deletes all of the other items & is set to 1 item.

I have tried deleting the ask for text/set variable for the last statement, and it results in the issue occurring on the "new" get value of variable.

Get variable stops appending

Best Answer

Running your workflow unedited...

In the fifth Get Value of Variable action, when running the original workflow, its Results, with the list button selected, was, e.g.,:

(
  "<NSAppleEventDescriptor: [ 'utxt'("Hey") ]>",
  "What's Up?",
  "1-3",
  "<NSAppleEventDescriptor: [ 'utxt'("Full QA") ]>",
  "<NSAppleEventDescriptor: [ 'utxt'("aren't") ]>"
)

In the sixth Get Value of Variable action, when running the original workflow, its Results, with the list button selected, was, e.g.,:

(
  "<NSAppleEventDescriptor: [ 'utxt'("Thank you") ]>"
)

When it would have beed expected to be, e.g.,:

(
  "<NSAppleEventDescriptor: [ 'utxt'("Hey") ]>",
  "What's Up?",
  "1-3",
  "<NSAppleEventDescriptor: [ 'utxt'("Full QA") ]>",
  "<NSAppleEventDescriptor: [ 'utxt'("aren't") ]>"
  "<NSAppleEventDescriptor: [ 'utxt'("Thank you") ]>"
)

Just to test something out, I converted all the Ask for Text actions to Run AppleScript actions that did the same thing, and initially converted all but the last Run JavaScript actions to Run AppleScript action and everything worked.

I then converted the last remaining Run JavaScript action to Run AppleScript action and everything worked. I did this because of the differences in how each variable was being saved/returned. Thus by making all the variables the same type/class it worked.

In the fifth Get Value of Variable action, when running the edited workflow, its Results, with the list button selected, was, e.g.,:

{"Hey", "What's Up?", "1-3", "Full QA", "aren't"}

In the sixth Get Value of Variable action, when running the edited workflow, its Results, with the list button selected, was, e.g.,:

{"Hey", "What's Up?", "1-3", "Full QA", "aren't", "Thank you"}

As you can see in the example results what's returned is a plain list of text strings not mixed as in the output of the original workflow.

The end result was, e.g.,:

enter image description here

While I can not say for sure, nonetheless, it looks like there may be some sort of bug with the type/class count when stacking more than five Get Value of Variable actions and why it does not fail when all have been acquired, set and retrieved when done using the same type of actions.


Here is a link for the edited workflow: Send_QA_Mail_Test.zip

  • SHA1: dfdec5414d0d5e22c46ad444b7bb77f19b442a45