# Script only runs when changing list level back and forth

**URL:** <https://forum.dynamobim.com/t/script-only-runs-when-changing-list-level-back-and-forth/88242>\
**Category:** Revit\
**Created:** [April 5, 2023, 8:04pm UTC](https://forum.dynamobim.com/t/script-only-runs-when-changing-list-level-back-and-forth/88242 "2023-04-05T20:04:38Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![LCzutor](https://avatars.discourse-cdn.com/v4/letter/l/ee7513/32.png) [@LCzutor](https://forum.dynamobim.com/u/LCzutor)\
**Post date:** [April 5, 2023, 8:04pm UTC](https://forum.dynamobim.com/t/script-only-runs-when-changing-list-level-back-and-forth/88242/1 "2023-04-05T20:04:39Z")

</div>

I am creating a script in Dynamo that will be opened up in a template file, and when I run the script, it will grab chosen parameters from that opened family, and transfer its value to other open families, changing the parameter value in those families (that have the same parameter name).

For some reason every single time I open up this script and start to run it, it gives an error message, and I have to disconnect and run it, and reconnect and run it, and then it works. Or I can change the list level back and forth, and it will work. But never for the first time.

Also, it never seems to be willing to do this process on both of the other families, only one at a time. One of them will always give an error code, and I have to change the list level back and forth for each one before each time I run it to get this final result that I want. But if I opened up this script again, it would not work immediately.  
What is happening here?

Here is a video as well: [Dynamo Problem - YouTube](https://youtu.be/Gh0QFl6l_ZU)

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/c/cc2122396c27157a9750041e21fcd082d7e829cc.jpeg)

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [April 5, 2023, 9:34pm UTC](https://forum.dynamobim.com/t/script-only-runs-when-changing-list-level-back-and-forth/88242/3 "2023-04-05T21:34:03Z")

</div>

What does the error say?

My guess is a transaction is required between selecting your data and running the `SetParameterValueByName` nodes. By default, Dynamo will wrap everything in the graph inside one Revit transaction. Some scenarios require a transaction to create an object and another transaction to utilize that object. (Example: One transaction to create a sheet in the project and another transaction to change its name.)

It’s also possible the `SetParameterValueByName` nodes can only write to one document at a time. That probably isn’t the case unless you’re trying to write to the _same_ family document with both.

---

<div class="post-metadata">

**Author:** ![LCzutor](https://avatars.discourse-cdn.com/v4/letter/l/ee7513/32.png) [@LCzutor](https://forum.dynamobim.com/u/LCzutor)\
**Post date:** [April 6, 2023, 1:07pm UTC](https://forum.dynamobim.com/t/script-only-runs-when-changing-list-level-back-and-forth/88242/4 "2023-04-06T13:07:44Z")

</div>

Thank you! This is the error code that I get:

Warning: FamilyDocument.SetParameterValueByName operation failed.  
A sub-transaction can only be active inside an open Transaction.

So how do I exactly fix that? I am not even sure what this transaction thing mean.

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [April 6, 2023, 1:27pm UTC](https://forum.dynamobim.com/t/script-only-runs-when-changing-list-level-back-and-forth/88242/5 "2023-04-06T13:27:57Z")

</div>

You can think of a transaction as the all-encompassing “action” that Revit sees in the command log. Dynamo runs as a single transaction when it’s pushed to Revit, so Revit only tracks that there was one Dynamo “action” even if you did multiple things within the graph.  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/c/3c83272c148a6497ec27001778bd36f8d848d255.png)

What this means is that nothing occurs in Revit until everything occurs in Revit, unless you add additional transactions. Try adding a `Transaction` node (start or stop is fine in this case) before writing to the parameter. You may also need a node that opens the `FamilyDocument` before writing to it as well.

If that still doesn’t work I’d suggest doing some more research on the forums for other topics dealing with writing to `FamilyDocuments` as there are some custom packages that are setup for exactly this and some specific best practices and workflows that go along with them.

---

<div class="post-metadata">

**Author:** ![LCzutor](https://avatars.discourse-cdn.com/v4/letter/l/ee7513/32.png) [@LCzutor](https://forum.dynamobim.com/u/LCzutor)\
**Post date:** [April 6, 2023, 1:31pm UTC](https://forum.dynamobim.com/t/script-only-runs-when-changing-list-level-back-and-forth/88242/6 "2023-04-06T13:31:02Z")

</div>

Thanks. I will try that.

---

<div class="post-metadata">

**Author:** ![LCzutor](https://avatars.discourse-cdn.com/v4/letter/l/ee7513/32.png) [@LCzutor](https://forum.dynamobim.com/u/LCzutor)\
**Post date:** [April 6, 2023, 1:39pm UTC](https://forum.dynamobim.com/t/script-only-runs-when-changing-list-level-back-and-forth/88242/7 "2023-04-06T13:39:19Z")

</div>

It worked! It’s very helpful, thanks!

---

<div class="post-metadata">

**Author:** ![LCzutor](https://avatars.discourse-cdn.com/v4/letter/l/ee7513/32.png) [@LCzutor](https://forum.dynamobim.com/u/LCzutor)\
**Post date:** [April 6, 2023, 2:40pm UTC](https://forum.dynamobim.com/t/script-only-runs-when-changing-list-level-back-and-forth/88242/8 "2023-04-06T14:40:40Z")

</div>

So the first issue was definitely solved, but when I try with multiple open documents, it can do only one at a time. The other ones will give the same message:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/e/8ee442487915d1674332dc6c7538740bc727da7d.jpeg)  
Is there a way to make this happen at once? I tried by adding some start and end nodes here, but then it did not work at all, but I might have put them at the wrong place.

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [April 6, 2023, 2:45pm UTC](https://forum.dynamobim.com/t/script-only-runs-when-changing-list-level-back-and-forth/88242/9 "2023-04-06T14:45:44Z")

</div>

I don’t think you can run them in parallel since they each need their own transaction. You would have to string them together to run one document after another, each with their own transaction. You can use a Wait or Passthrough node to force the order if you have to.

---

<div class="post-metadata">

**Author:** ![LCzutor](https://avatars.discourse-cdn.com/v4/letter/l/ee7513/32.png) [@LCzutor](https://forum.dynamobim.com/u/LCzutor)\
**Post date:** [April 6, 2023, 3:09pm UTC](https://forum.dynamobim.com/t/script-only-runs-when-changing-list-level-back-and-forth/88242/10 "2023-04-06T15:09:09Z")

</div>

What do you think of this? Should be applied to all input? It seems that I got this message again.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/3/231f197d23e3ba3b017720166bbecf66893b6827.jpeg)

---

<div class="post-metadata">

**Author:** ![LCzutor](https://avatars.discourse-cdn.com/v4/letter/l/ee7513/32.png) [@LCzutor](https://forum.dynamobim.com/u/LCzutor)\
**Post date:** [April 6, 2023, 3:13pm UTC](https://forum.dynamobim.com/t/script-only-runs-when-changing-list-level-back-and-forth/88242/11 "2023-04-06T15:13:08Z")

</div>

Same issue 😕

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/c/6c54ba8e6ed8bf214d32001ecd6be789d0f1de10.jpeg)

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [April 6, 2023, 3:24pm UTC](https://forum.dynamobim.com/t/script-only-runs-when-changing-list-level-back-and-forth/88242/12 "2023-04-06T15:24:05Z")

</div>

One wait node per document should be enough, but you still need a transaction node in between as well.

---

<div class="post-metadata">

**Author:** ![LCzutor](https://avatars.discourse-cdn.com/v4/letter/l/ee7513/32.png) [@LCzutor](https://forum.dynamobim.com/u/LCzutor)\
**Post date:** [April 6, 2023, 3:37pm UTC](https://forum.dynamobim.com/t/script-only-runs-when-changing-list-level-back-and-forth/88242/13 "2023-04-06T15:37:31Z")

</div>

Thanks. This is how I actually modified it before I saw your latest reply, but this didn’t work. Did I put the transaction node to the wrong place? The error code is still the same:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/4/4425d44aeaa5d386f28804e6ea3d5ab91c643bf9.jpeg)

---

<div class="post-metadata">

**Author:** ![LCzutor](https://avatars.discourse-cdn.com/v4/letter/l/ee7513/32.png) [@LCzutor](https://forum.dynamobim.com/u/LCzutor)\
**Post date:** [April 6, 2023, 3:45pm UTC](https://forum.dynamobim.com/t/script-only-runs-when-changing-list-level-back-and-forth/88242/15 "2023-04-06T15:45:06Z")

</div>

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/0/30b4a77f94faec5678af94abfa99308d835f3226.jpeg)

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [April 6, 2023, 3:46pm UTC](https://forum.dynamobim.com/t/script-only-runs-when-changing-list-level-back-and-forth/88242/16 "2023-04-06T15:46:51Z")

</div>

You may have to do a full Start and Stop for each transaction now, so two nodes per document.
