# How do I add a move node (child) to an IfNode? (when creating a Template from Java)

**URL:** <https://forum.universal-robots.com/t/how-do-i-add-a-move-node-child-to-an-ifnode-when-creating-a-template-from-java/25902>\
**Category:** Java\
**Created:** [January 2, 2023, 9:23am UTC](https://forum.universal-robots.com/t/how-do-i-add-a-move-node-child-to-an-ifnode-when-creating-a-template-from-java/25902 "2023-01-02T09:23:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![benny.stromberg](https://avatars.discourse-cdn.com/v4/letter/b/b2d939/32.png) [@benny.stromberg](https://forum.universal-robots.com/u/benny.stromberg)\
**Post date:** [January 2, 2023, 9:23am UTC](https://forum.universal-robots.com/t/how-do-i-add-a-move-node-child-to-an-ifnode-when-creating-a-template-from-java/25902/1 "2023-01-02T09:23:27Z")

</div>

I create a Template in my URcap to simplify for the user.

In this template I want to use an IfNode. Creating the IfNode is no problem, however I cannot find information in the 1.8.0 Api on  
how to add a node in the If.

![image](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/2X/3/3117bf6a939f618b2df31b1f1bcdeca4742c9497.png)

Thank you all in advance!  
-Benny

---

<div class="post-metadata">

**Author:** ![benny.stromberg](https://avatars.discourse-cdn.com/v4/letter/b/b2d939/32.png) [@benny.stromberg](https://forum.universal-robots.com/u/benny.stromberg)\
**Post date:** [January 2, 2023, 3:30pm UTC](https://forum.universal-robots.com/t/how-do-i-add-a-move-node-child-to-an-ifnode-when-creating-a-template-from-java/25902/2 "2023-01-02T15:30:51Z")

</div>

I found the solution myself,

Instead of adding the IfNode directly to the root tree I create an TreeNode ifNodeTreeNode and then add the ifNode as a child.  
After that it is possible to add children to the IfNode, below is some of my test code.

root\_ = programModel\_.getRootTreeNode(programNode\_.get());  
TreeNode ifNodeTreeNode = root\_ .addChild(createIfNode(“digital\_in[0]”,“true”));  
FolderNode testFolderNode = programNodeFactory\_.createFolderNode();  
String folderNametest = “TestFolder”;  
testFolderNode.setName(folderNametest);  
ifNodeTreeNode.addChild(testFolderNode);

![image](https://us1.discourse-cdn.com/flex020/uploads/universal_robots/original/2X/7/7b9d9e0d1e86e50e9f69fd4933e5d379decba9cd.png)

/Benny
