# Remove Contact Type

**URL:** <https://forum.inductiveautomation.com/t/remove-contact-type/20164>\
**Category:** Module Development\
**Created:** [October 15, 2018, 8:50pm UTC](https://forum.inductiveautomation.com/t/remove-contact-type/20164 "2018-10-15T20:50:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![camatt3](https://avatars.discourse-cdn.com/v4/letter/c/22d042/32.png) [@camatt3](https://forum.inductiveautomation.com/u/camatt3)\
**Post date:** [October 15, 2018, 8:50pm UTC](https://forum.inductiveautomation.com/t/remove-contact-type/20164/1 "2018-10-15T20:50:10Z")

</div>

I would like to be able to remove a registered ContactType.  
I’ve added one using  
`gatewayContext.getUserSourceManager().registerContactType(newContactType);`  
and tried to remove one using  
`gatewayContext.getUserSourceManager().getRegisteredContactTypes().remove(oldContactType);`  
It doesn’t seem to get removed from the system (I’m guessing getRegisteredContactTypes() is creating a new Set).  
Is there a way to do this?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [October 15, 2018, 9:00pm UTC](https://forum.inductiveautomation.com/t/remove-contact-type/20164/2 "2018-10-15T21:00:20Z")

</div>

It doesn’t look like there’s a way to do this in the current API, no. What’s the use case? Each gateway startup the contact type would have to be explicitly registered to appear to end-users, so if you remove the module your new contact types will be (visibly) cleared up on the next restart.

That said, if you _really_ need this functionality, it should be possible with some reflection, though that is absolutely going to break in 8.0+. The (private) field on the UserSourceManagerImpl class is just `contactTypes`. I’ll leave the rest an exercise for the reader.

---

<div class="post-metadata">

**Author:** ![camatt3](https://avatars.discourse-cdn.com/v4/letter/c/22d042/32.png) [@camatt3](https://forum.inductiveautomation.com/u/camatt3)\
**Post date:** [October 15, 2018, 9:19pm UTC](https://forum.inductiveautomation.com/t/remove-contact-type/20164/3 "2018-10-15T21:19:10Z")

</div>

My module adds a new notification profile type, and for each instance created of that type on the gateway I wanted to add a new ContactType. So, when sending a notification with a given profile, only contacts relating to that profile would be notified.

I don’t think I need the functionality enough to take the reflection route, so might have to rethink my approach.
