# Check if tags created

**URL:** <https://forum.genieacs.com/t/check-if-tags-created/3133>\
**Category:** Uncategorized\
**Created:** [November 1, 2022, 1:05pm UTC](https://forum.genieacs.com/t/check-if-tags-created/3133 "2022-11-01T13:05:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![egor.gr](https://avatars.discourse-cdn.com/v4/letter/e/7ea924/32.png) [@egor.gr](https://forum.genieacs.com/u/egor.gr)\
**Post date:** [November 1, 2022, 1:05pm UTC](https://forum.genieacs.com/t/check-if-tags-created/3133/1 "2022-11-01T13:05:45Z")

</div>

Hello.  
Is there a way to check if tag was created for device or not in provision script?  
When i tag a device with a tag “MyTag” and if i use in provision script:

```auto
let IfMyTag=declare("Tags.MyTag", {value: 1}).value[0];
log(IfMyTag);

```

Then i get true in the logs.  
But if i remove MyTag from device i see in the logs:  
`script.TypeError" faultMessage="Cannot read properties of undefined (reading '0')`

I am trying to make 2 different scenarios:  
When MyTag presents-nothing to do  
When MyTag doen’s presents on device-do something and then add MyTag with  
`declare("Tags.MyTag", null, {value: true});`

Is it possible? And if yes-how?

---

<div class="post-metadata">

**Author:** ![akcoder](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/akcoder/32/11_2.png) [@akcoder](https://forum.genieacs.com/u/akcoder)\
**Post date:** [November 1, 2022, 4:02pm UTC](https://forum.genieacs.com/t/check-if-tags-created/3133/2 "2022-11-01T16:02:04Z")

</div>

You are using the wrong syntax for tags. The value property on tags isn’t an array that can be indexed, hence “Cannot read properties of undefined (reading ‘0’)”. Use this function if you’d like to make things easier.

```auto
function hasTag(name) {
    return declare(`Tags.${name}`, {value: 1}).value !== undefined;
}

```

---

<div class="post-metadata">

**Author:** ![egor.gr](https://avatars.discourse-cdn.com/v4/letter/e/7ea924/32.png) [@egor.gr](https://forum.genieacs.com/u/egor.gr)\
**Post date:** [November 2, 2022, 7:43am UTC](https://forum.genieacs.com/t/check-if-tags-created/3133/3 "2022-11-02T07:43:25Z")

</div>

And in name i should use tag name?  
In my case MyTag?

---

<div class="post-metadata">

**Author:** ![egor.gr](https://avatars.discourse-cdn.com/v4/letter/e/7ea924/32.png) [@egor.gr](https://forum.genieacs.com/u/egor.gr)\
**Post date:** [November 2, 2022, 7:46am UTC](https://forum.genieacs.com/t/check-if-tags-created/3133/4 "2022-11-02T07:46:28Z")

</div>

Yep, now it is true or false without errors.  
Many thanks

---

<div class="post-metadata">

**Author:** ![abran3d](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@abran3d](https://forum.genieacs.com/u/abran3d)\
**Post date:** [November 2, 2022, 4:17pm UTC](https://forum.genieacs.com/t/check-if-tags-created/3133/5 "2022-11-02T16:17:05Z")

</div>

this link has what you need.  
[Example of a Provisioning Flow · genieacs/genieacs Wiki · GitHub](https://github.com/genieacs/genieacs/wiki/Example-of-a-Provisioning-Flow)
