# Get users usersource when using system.alarm.getRosters()

**URL:** <https://forum.inductiveautomation.com/t/get-users-usersource-when-using-system-alarm-getrosters/99685>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [December 11, 2024, 1:36pm UTC](https://forum.inductiveautomation.com/t/get-users-usersource-when-using-system-alarm-getrosters/99685 "2024-12-11T13:36:55Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![liam1](https://avatars.discourse-cdn.com/v4/letter/l/e68b1a/32.png) [@liam1](https://forum.inductiveautomation.com/u/liam1)\
**Post date:** [December 11, 2024, 1:36pm UTC](https://forum.inductiveautomation.com/t/get-users-usersource-when-using-system-alarm-getrosters/99685/1 "2024-12-11T13:36:55Z")

</div>

Hello everyone,

I am currently utilizing a Teltonika device and its API to send alarm SMS messages. Specifically, I am using the `system.alarm.getRosters() ` function to retrieve a list of users associated with a specific roster, along with their contact details.

However, I have encountered a challenge: rosters can consist of users from various sources, and when I access the roster information, it does not indicate which user source each user was added from. As a result, I am forced to use a static user source when retrieving contact information, rather than being able to programmatically access this metadata within my script.

This limitation complicates the setup of rosters that include users from different sources. Is there a way to obtain this user source information programmatically?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [December 11, 2024, 1:55pm UTC](https://forum.inductiveautomation.com/t/get-users-usersource-when-using-system-alarm-getrosters/99685/2 "2024-12-11T13:55:54Z")

</div>

It's undocumented and only works in Gateway scope, but I think you can call `system.alarm.getRoster(rosterName)` to get a `RosterModel` object, which has actual `User` objects in it (`RosterModel::getUsers()`), which should include profile and contact info.

---

<div class="post-metadata">

**Author:** ![liam1](https://avatars.discourse-cdn.com/v4/letter/l/e68b1a/32.png) [@liam1](https://forum.inductiveautomation.com/u/liam1)\
**Post date:** [December 11, 2024, 2:10pm UTC](https://forum.inductiveautomation.com/t/get-users-usersource-when-using-system-alarm-getrosters/99685/3 "2024-12-11T14:10:27Z")

</div>

Got it working, thanks.

```python
def test():
	logger=system.util.getLogger('api_test')
	ros='ROS_Test'
	roster = system.alarm.getRoster(ros)
	for user_object in roster.getUsers():
		contacts= user_object.getContactInfo()
		for contact in contacts:
			if contact.contactType=='sms' or contact.contactType=='phone':
				number=contact.getValue()
				logger.info(str(number))
	return 

```

---

<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:** [December 11, 2024, 4:14pm UTC](https://forum.inductiveautomation.com/t/get-users-usersource-when-using-system-alarm-getrosters/99685/4 "2024-12-11T16:14:27Z")

</div>

> [@Kevin.Herron](#):
>
> It's undocumented and only works in Gateway scope

`system.roster.getRoster` does the same operation and is supported:

> **[system.roster.getRoster | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-roster/system-roster-getRoster)**
>
> Returns the roster corresponding to the given name.

I don't remember the rationale for having `system.alarm` and `system.roster` functions 🤷‍♂️

---

<div class="post-metadata">

**Author:** ![liam1](https://avatars.discourse-cdn.com/v4/letter/l/e68b1a/32.png) [@liam1](https://forum.inductiveautomation.com/u/liam1)\
**Post date:** [January 10, 2025, 12:57pm UTC](https://forum.inductiveautomation.com/t/get-users-usersource-when-using-system-alarm-getrosters/99685/5 "2025-01-10T12:57:05Z")

</div>

Something weird is happening there , when I try and get the user notes it doesn't work?

I can see the notes data in the `getRawValueMap()` but not matter what I do cannot access it typecasting to python dictionary or using the `get()` method?

```python
		# get the roster model for using the roster name
		roster = system.alarm.getRoster(roster)
		# get the users found in the roster model
		users= roster.getUsers()
		# array for storing the numbers
		roster_numbers=[]
		# loop throught each user model found in the roster model
		for user_object in users:
			# extract the users contact information
			
			notes= user_object.get("notes")

```

---

<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:** [January 10, 2025, 4:27pm UTC](https://forum.inductiveautomation.com/t/get-users-usersource-when-using-system-alarm-getrosters/99685/6 "2025-01-10T16:27:13Z")

</div>

Try:

```python
notes = user_object.get(user_object.Notes)

```

When it's not a "PyUser", for complicated/hard to explain reasons, you have to use specific accessor fields as the 'keys' to `get()`.

---

<div class="post-metadata">

**Author:** ![liam1](https://avatars.discourse-cdn.com/v4/letter/l/e68b1a/32.png) [@liam1](https://forum.inductiveautomation.com/u/liam1)\
**Post date:** [January 13, 2025, 7:21am UTC](https://forum.inductiveautomation.com/t/get-users-usersource-when-using-system-alarm-getrosters/99685/7 "2025-01-13T07:21:23Z")

</div>

That worked thanks.

I am trying to update the user notes via scripting but the `.set() ` method doesn't seem to work.

Here is the code script im using

```python
user = system.user.getUser("default", "liam")
user.set('Notes','test')
system.user.editUser("default", user)

```

I also tried using the `.set(user.Notes,'test') ` but this also doesn't work.

---

<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:** [January 13, 2025, 4:38pm UTC](https://forum.inductiveautomation.com/t/get-users-usersource-when-using-system-alarm-getrosters/99685/8 "2025-01-13T16:38:57Z")

</div>

> [@liam1](#):
>
> .set(user.Notes,'test')

It would definitely be this form, just like accessing the property. If you make other edits, are those applied? Any errors in the gateway logs, or on the UIResponse object you get back?

---

<div class="post-metadata">

**Author:** ![liam1](https://avatars.discourse-cdn.com/v4/letter/l/e68b1a/32.png) [@liam1](https://forum.inductiveautomation.com/u/liam1)\
**Post date:** [January 13, 2025, 4:48pm UTC](https://forum.inductiveautomation.com/t/get-users-usersource-when-using-system-alarm-getrosters/99685/9 "2025-01-13T16:48:24Z")

</div>

I get a UIReponise object back , but when I go into the user profile on the gateway I don't see any changes.

Should I check the information contained in the UIResponse object?

---

<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:** [January 13, 2025, 4:55pm UTC](https://forum.inductiveautomation.com/t/get-users-usersource-when-using-system-alarm-getrosters/99685/10 "2025-01-13T16:55:50Z")

</div>

Yes, examine the UI Response for `info`, `errors`, and `warns`:  
[https://files.inductiveautomation.com/sdk/javadoc/ignition80/8.0.12/com/inductiveautomation/ignition/common/messages/UIResponse.html](https://files.inductiveautomation.com/sdk/javadoc/ignition80/8.0.12/com/inductiveautomation/ignition/common/messages/UIResponse.html)

---

<div class="post-metadata">

**Author:** ![liam1](https://avatars.discourse-cdn.com/v4/letter/l/e68b1a/32.png) [@liam1](https://forum.inductiveautomation.com/u/liam1)\
**Post date:** [January 14, 2025, 6:19am UTC](https://forum.inductiveautomation.com/t/get-users-usersource-when-using-system-alarm-getrosters/99685/11 "2025-01-14T06:19:06Z")

</div>

Okay found the error `[You are not authorized to modify the Gateway system user source.] `  
Is there a setting in the gateway to allow this to be done via scripting?

---

<div class="post-metadata">

**Author:** ![liam1](https://avatars.discourse-cdn.com/v4/letter/l/e68b1a/32.png) [@liam1](https://forum.inductiveautomation.com/u/liam1)\
**Post date:** [January 14, 2025, 6:23am UTC](https://forum.inductiveautomation.com/t/get-users-usersource-when-using-system-alarm-getrosters/99685/12 "2025-01-14T06:23:54Z")

</div>

Found the setting from this [thread](https://forum.inductiveautomation.com/t/user-management/11818/5)
