# Add,edit,delete tags from one gateway and push changes to other gateway

**URL:** <https://forum.inductiveautomation.com/t/add-edit-delete-tags-from-one-gateway-and-push-changes-to-other-gateway/53878>\
**Category:** Ignition\
**Created:** [December 8, 2021, 12:20pm UTC](https://forum.inductiveautomation.com/t/add-edit-delete-tags-from-one-gateway-and-push-changes-to-other-gateway/53878 "2021-12-08T12:20:01Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [December 8, 2021, 12:20pm UTC](https://forum.inductiveautomation.com/t/add-edit-delete-tags-from-one-gateway-and-push-changes-to-other-gateway/53878/1 "2021-12-08T12:20:01Z")

</div>

Hi,

I am trying to **create a perspective project on Data center gateway**.

In that i am trying to **add tag and push the new added tag to plant gateway**. Where i have a tags created in **default provider** (In that provider i need to add the tag which i pushed)

how to do this one… can any one share your ideas please?

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [December 8, 2021, 12:34pm UTC](https://forum.inductiveautomation.com/t/add-edit-delete-tags-from-one-gateway-and-push-changes-to-other-gateway/53878/2 "2021-12-08T12:34:21Z")

</div>

i suppose you will have to send a message to the other gateway with the correct payloads and there use  
[https://docs.inductiveautomation.com/display/DOC81/system.tag.configure](https://docs.inductiveautomation.com/display/DOC81/system.tag.configure)

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [December 8, 2021, 12:47pm UTC](https://forum.inductiveautomation.com/t/add-edit-delete-tags-from-one-gateway-and-push-changes-to-other-gateway/53878/3 "2021-12-08T12:47:26Z")

</div>

thanks i will check it out

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [December 8, 2021, 4:40pm UTC](https://forum.inductiveautomation.com/t/add-edit-delete-tags-from-one-gateway-and-push-changes-to-other-gateway/53878/4 "2021-12-08T16:40:43Z")

</div>

I had to do something like this not long ago, I did use messages:  
A message handler gateway event script that receives the data and writes it to a tag,  
And a `system.util.sendMessage()` call on the other gateway that sends the appropriate data:

```python
system.util.sendMessage(target_project, message_handler, payload=payload, remoteServers=[target_gateway])

```

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [December 8, 2021, 5:24pm UTC](https://forum.inductiveautomation.com/t/add-edit-delete-tags-from-one-gateway-and-push-changes-to-other-gateway/53878/5 "2021-12-08T17:24:40Z")

</div>

Ok i will use this function… I am trying add or edit or delete a tag to a corresponding folder in another gateway

For that system.tag.configure i need to use this one.

How to link this function and your util. Message(i mean payload function)

I am trying to push my changes from one gateway to another gateway

Any example script can you able to give?

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [December 9, 2021, 8:51am UTC](https://forum.inductiveautomation.com/t/add-edit-delete-tags-from-one-gateway-and-push-changes-to-other-gateway/53878/6 "2021-12-09T08:51:38Z")

</div>

Don’t script it on the gateway that sends the message, but on the gateway that receives it.  
You put it in the gateway event scripts, there’s a `message` section there:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/e/0e0c4fab8974f2e9b9ea3d033c2aa3ae695ddf1a.png)  
That’s a message handler, let’s call it `testHandler`  
In this script, you call `system.tag.configure()` to add your tag, or do whatever you need to do.

Now, in the sending project, when you want to call this script, you just call

```python
target_project = <the name of the receiving project>
target_gateway = <the gateway where the receiving project is>
payload = <a dictionnary of data you want to send, can be empty>
system.util.sendMessage(target_project, 'testHandler', payload=payload, remoteServers=[target_gateway])

```

`remoteServers` needs to be a list, that why there are `[]` surrounding `target_gateway`.

And that’s it.

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [December 9, 2021, 10:03am UTC](https://forum.inductiveautomation.com/t/add-edit-delete-tags-from-one-gateway-and-push-changes-to-other-gateway/53878/7 "2021-12-09T10:03:00Z")

</div>

One doubt how to pass this to payload like this

`payload = [system.tag.configure(baseTagPath, tags, collisionPolicy)]`

is it correct?

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [December 9, 2021, 10:25am UTC](https://forum.inductiveautomation.com/t/add-edit-delete-tags-from-one-gateway-and-push-changes-to-other-gateway/53878/8 "2021-12-09T10:25:38Z")

</div>

No !

You don’t pass the function, the script in the message handler already knows what to do. The payload is only data you need to PASS to `system.tag.configure()` or to compute its parameters.

Let’s do a concrete example.  
Say you want to create a memory tag named `foo`, with value `bar` on gateway `GWA`, which has a project `A`, when a button in the project `B` that is on gateway `GWB` is clicked.

In project `A`, you make a `message` script in the gateway event scripts, and you call it `addTag`:

```python
tag = payload.tag
path = payload.path
system.tag.configure(path, tag, 'o')

```

This is in charge of configuring a tag at path `path`.

Now, on the `onActionPerformed` event of your button, you add this:

```python
path = "[]baz"
tag = {
	'name': "foo",
	'valueSource': "memory",
	'dataType': "String",
	'value': "bar",
	'tagType': "AtomicTag"
}
payload = {
	path: path,
	tag: tag
}
system.util.sendMessage('A', 'addTag', payload=payload, remoteServers=['GWA'])

```

This sends ONLY sends a message that needs to be intercepted by an handler called `addTag`, in project `A`, that lives in gateway `GWA`, with some data that’s conventionally called `payload`.

When the message is sent, the handler in project `A` receives it, and does whatever it was configured to do. Here, it will use the data in payload to create a tag.

Project `B` has no notion of writing tags or calling function, all it does is toss a bottle in the ocean, with a label on it that says `this is for A !` and a piece of paper inside where the payload is written.  
When `A` find the bottle, it opens it, reads the paper inside and does its thing. Turns out, its thing is writing tags based on papers it finds in bottles.

Now, there are ways of doing it differently. You could actually send a function name as payload, to give more specific instructions. But this gets more complicated, and you don’t need it in your case.

edit:  
Adapt the above example to match your case, for example if all the tags you need to write are memory tags of type String at the same location, you could just pass the name and the value of the tag and let the handler construct the tag:  
on `B`:

```python
payload = {
    name: "foo"
    value: "bar"
}
system.util.sendMessage('A', 'addTag', payload=payload, remoteServers=['GWA'])

```

and on `A`:

```python
tag = {
	'name': payload.name,
	'valueSource': "memory",
	'dataType': "String",
	'deadbandMode': "Off",
	'value': name.value,
	'tagType': "AtomicTag"
}
system.tag.configure("[]thisIsThePath", tag, 'o')

```

---

<div class="post-metadata">

**Author:** ![prasath.t](https://avatars.discourse-cdn.com/v4/letter/p/898d66/32.png) [@prasath.t](https://forum.inductiveautomation.com/u/prasath.t)\
**Post date:** [December 9, 2021, 10:41am UTC](https://forum.inductiveautomation.com/t/add-edit-delete-tags-from-one-gateway-and-push-changes-to-other-gateway/53878/9 "2021-12-09T10:41:25Z")

</div>

Thanks a lot for your clear explanation. I will implement this one and check
