# Help with addTag

**URL:** <https://forum.inductiveautomation.com/t/help-with-addtag/5250>\
**Category:** 3rd Party Modules\
**Created:** [October 8, 2012, 7:52pm UTC](https://forum.inductiveautomation.com/t/help-with-addtag/5250 "2012-10-08T19:52:44Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bob](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bob/32/16899_2.png) [@Bob](https://forum.inductiveautomation.com/u/Bob)\
**Post date:** [October 8, 2012, 7:52pm UTC](https://forum.inductiveautomation.com/t/help-with-addtag/5250/1 "2012-10-08T19:52:44Z")

</div>

If I use the following in the Script Playground, my tag gets created as expected:

```
    system.tag.addTag(parentPath="MyServer OPC DA", name="Test Tag3", tagType="OPC", dataType="Int4")

```

If I use the same syntax in a Gateway Startup Script, the tag is not created and in the wrapper.log I get the error:

```
    "TypeError: addTag(): takes no keyword arguments"

```

So I change the syntax to be:

```
    system.tag.addTag(MyServer OPC DA", Test Tag4", OPC", Int4")

```

But then I get the error:

```
   "TypeError: addTag(): expected 8 args; got 4"

```

What are the other required arguments when running as a Gateway Startup Script?

Thanks,  
Bob

---

<div class="post-metadata">

**Author:** ![Colby.Clegg](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/colby.clegg/32/3282_2.png) [@Colby.Clegg](https://forum.inductiveautomation.com/u/Colby.Clegg)\
**Post date:** [October 8, 2012, 8:01pm UTC](https://forum.inductiveautomation.com/t/help-with-addtag/5250/2 "2012-10-08T20:01:34Z")

</div>

Hi,

It looks like there might be a problem with the use of keyword invocation on the gateway scoped portion of this module (that is, the gateway side isn’t set up to use keywords). Try calling the function normally, with a parameter for each field. In other words, much like your second attempt, but will a value (possibly ‘null’) for each argument. Here is the signature:

`void addTag(String parentPath, String name, TagType tagType, DataType dataType,
			AccessRightsType accessRights, boolean enabled, BasicTagValue value, MetaTagValue[] attributes,
			AlarmStateList alarmList)`

Regards,

---

<div class="post-metadata">

**Author:** ![Bob](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bob/32/16899_2.png) [@Bob](https://forum.inductiveautomation.com/u/Bob)\
**Post date:** [October 8, 2012, 8:40pm UTC](https://forum.inductiveautomation.com/t/help-with-addtag/5250/3 "2012-10-08T20:40:34Z")

</div>

I tried with:

system.tag.addTag(“MyServer OPC DA”, “Test Tag4”, “OPC”, “Int4”, ‘null’, ‘null’, ‘null’, ‘null’)

And then got the error:

TypeError: addTag(): 3rd arg can’t be coerced to com.inductiveautomation.ignition.common.sqltags.model.types.TagType

So I have tried various options using “6” for a TagType parameter (as shown below), or even “property” among other things but I always get the same error.

system.tag.addTag(“MyServer OPC DA”, “Test Tag4”, “6”, “Int4”, ‘null’, ‘null’, ‘null’, ‘null’)  
system.tag.addTag(“MyServer OPC DA”, “Test Tag4”, 6, “Int4”, ‘null’, ‘null’, ‘null’, ‘null’)  
system.tag.addTag(“MyServer OPC DA”, “Test Tag4”, “Property”, “Int4”, ‘null’, ‘null’, ‘null’, ‘null’)

What is this parameter expecting?

Thanks,  
Bob

---

<div class="post-metadata">

**Author:** ![Colby.Clegg](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/colby.clegg/32/3282_2.png) [@Colby.Clegg](https://forum.inductiveautomation.com/u/Colby.Clegg)\
**Post date:** [October 8, 2012, 10:15pm UTC](https://forum.inductiveautomation.com/t/help-with-addtag/5250/4 "2012-10-08T22:15:33Z")

</div>

Ah, I had that thought when I posted, but hoped that it would coerce from the string form. Ultimately, the module should be updated to support keywords - which in turn uses more permissive coercion. However, in the mean time, if you want to use it as is, you’ll need to import the Java type objects into Jython and use them like this:

```auto
from com.inductiveautomation.ignition.common.sqltags.model.types import TagType, DataType, AccessRightsType

system.tag.addTag("MyServer OPC DA", "Test Tag4", TagType.OPC, DataType.Int4, AccessRightsType.Read_Write, true, null, null, null)
```

Regards,

---

<div class="post-metadata">

**Author:** ![Bob](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bob/32/16899_2.png) [@Bob](https://forum.inductiveautomation.com/u/Bob)\
**Post date:** [October 9, 2012, 2:48pm UTC](https://forum.inductiveautomation.com/t/help-with-addtag/5250/5 "2012-10-09T14:48:48Z")

</div>

Has your last statement been tested? If it works then perhaps I need to download a newer version of Ignition.

So far I needed to change “true” to “True” and the Null to ‘null’, and it had an error with having 9 arguments when it only wanted 8 arguments. My latest statement is:

system.tag.addTag(“MyServer OPC DA”, “Test Tag4”, TagType.OPC, DataType.Int4, AccessRightsType.Read\_Write, True, ‘null’, ‘null’)

But I still get the error:

TypeError: addTag(): 7th arg can’t be coerced to com.inductiveautomation.ignition.common.sqltags.BasicTagValue

Thanks,  
Bob

---

<div class="post-metadata">

**Author:** ![Colby.Clegg](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/colby.clegg/32/3282_2.png) [@Colby.Clegg](https://forum.inductiveautomation.com/u/Colby.Clegg)\
**Post date:** [October 9, 2012, 3:56pm UTC](https://forum.inductiveautomation.com/t/help-with-addtag/5250/6 "2012-10-09T15:56:35Z")

</div>

Sorry, I was trying to post quickly yesterday, and guessed wrong on a few things. Here’s the correct form, which I’ve tested:

`from com.inductiveautomation.ignition.common.sqltags.model.types import TagType, DataType, AccessRightsType
system.tag.addTag("MyServer OPC DA", "Test Tag4", TagType.OPC, DataType.Int4, AccessRightsType.Read_Write, True, None, None)`

In Jython, null = None. You’re passing it a string that happens to have the value ‘null’, which is why it can’t coerce.

Now, that said, I think it’s probably going to be easier if you wait until the module is updated to support keyword invocation, because if you’re trying to create OPC tags, you’ll need to pass in parameters for the tag properties needed, such as opc server, and opc item path, and right now that’s going to be really annoying to create. I’ll see if we can get it updated today or tomorrow.

Regards,

---

<div class="post-metadata">

**Author:** ![Bob](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bob/32/16899_2.png) [@Bob](https://forum.inductiveautomation.com/u/Bob)\
**Post date:** [October 9, 2012, 4:06pm UTC](https://forum.inductiveautomation.com/t/help-with-addtag/5250/7 "2012-10-09T16:06:44Z")

</div>

Yes, that worked, thank you.

Right now I am just trying to do some basic proof of concept on our end, so this is good for immediate need. Though I will be interested when the final changes for the module are complete.

Cheers!  
Bob

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [October 10, 2012, 2:54am UTC](https://forum.inductiveautomation.com/t/help-with-addtag/5250/8 "2012-10-10T02:54:06Z")

</div>

We will have the fix by the end of the week. I will post back once the changes are made.

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [October 13, 2012, 1:08am UTC](https://forum.inductiveautomation.com/t/help-with-addtag/5250/9 "2012-10-13T01:08:27Z")

</div>

Ok, we have fixed the module in version 1.1.0. You can download it here:

[viewtopic.php?f=88&t=8823](http://inductiveautomation.com/forum/viewtopic.php?f=88&t=8823)

---

<div class="post-metadata">

**Author:** ![Z\_M\_S](https://avatars.discourse-cdn.com/v4/letter/z/e274bd/32.png) [@Z\_M\_S](https://forum.inductiveautomation.com/u/Z_M_S)\
**Post date:** [October 17, 2012, 9:37am UTC](https://forum.inductiveautomation.com/t/help-with-addtag/5250/10 "2012-10-17T09:37:31Z")

</div>

Hi. I have some problems with tag, created by system.tag.addTag().

I have done this code in my gateway timer script:

```auto
from com.inductiveautomation.ignition.common.sqltags.model.types import TagType, DataType, AccessRightsType

if (system.tag.exists("[default]Ignition OPC-UA Server/LastPPO") == 0):
	system.tag.addTag("Ignition OPC-UA Server", "LastPPO", TagType.OPC, DataType.Int4, AccessRightsType.Read_Write, True, None, None)
if (system.tag.exists("[default]Ignition OPC-UA Server/PrevPPO") == 0):
	system.tag.addTag("Ignition OPC-UA Server", "PrevPPO", TagType.OPC, DataType.Int4, AccessRightsType.Read_Write, True, None, None)

if (system.tag.write("[default]Ignition OPC-UA Server/PrevPPO",value)) == 1: 
        if (system.tag.write("[default]Ignition OPC-UA Server/LastPPO",PPO)) == 1:
		if system.tag.read("[default]Ignition OPC-UA Server/PrevPPO").value != None:
			.... some kind of code...
```

It is very possible, that I have done something wrong, because after series of this script’s works, i saw next in Ignition Designer’s OPC browser:

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/c/9cbcc6de9254a6834dbbc3c5191d93b5144f5a24.png)

And, I saw next in a OPC servers statuse page:

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/b/8bd68e5aae8483b5006235043e6608b56563e119.png)

What am I need to do, to remove empty server and to work properly with tag, created by gateway script?

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [October 19, 2012, 6:40pm UTC](https://forum.inductiveautomation.com/t/help-with-addtag/5250/11 "2012-10-19T18:40:40Z")

</div>

The addTag function doesn’t add OPC servers. Did you add those OPC servers manually?
