# Set User Properties through Scripting

**URL:** <https://forum.inductiveautomation.com/t/set-user-properties-through-scripting/56423>\
**Category:** Ignition\
**Created:** [February 22, 2022, 8:47pm UTC](https://forum.inductiveautomation.com/t/set-user-properties-through-scripting/56423 "2022-02-22T20:47:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tim.schultz](https://avatars.discourse-cdn.com/v4/letter/t/71e660/32.png) [@tim.schultz](https://forum.inductiveautomation.com/u/tim.schultz)\
**Post date:** [February 22, 2022, 8:47pm UTC](https://forum.inductiveautomation.com/t/set-user-properties-through-scripting/56423/1 "2022-02-22T20:47:59Z")

</div>

I’m trying to set a user’s badge ID through scripting. I’ve tried this, but it does not work… any suggestions on what I’m missing?

```auto
def updateUserBadge(userSource,userName,badgeNumber="1234567"):
	# Retrieve the user we're going to edit.
	userToChange = system.user.getUser(userSource, userName)
	userToChange.set("Badge",badgeNumber)
	system.user.editUser(userSource, userToChange)

updateUserBadge("adminGroup","tim")

```

---

<div class="post-metadata">

**Author:** ![awaege1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/awaege1/32/28922_2.png) [@awaege1](https://forum.inductiveautomation.com/u/awaege1)\
**Post date:** [February 22, 2022, 9:30pm UTC](https://forum.inductiveautomation.com/t/set-user-properties-through-scripting/56423/2 "2022-02-22T21:30:32Z")

</div>

I’m not entirely sure here but I did run into something like this when dealing with alarm event objects. I remember having to actually create the static property being used to update the object before setting it. Someone else will probably have a better understanding of this than I but it may be worth it to look at the object structure in the java docs here: [PyUser](http://files.inductiveautomation.com/sdk/javadoc/ignition80/8.0.12/com/inductiveautomation/ignition/common/user/PyUser.html)

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [February 22, 2022, 9:57pm UTC](https://forum.inductiveautomation.com/t/set-user-properties-through-scripting/56423/3 "2022-02-22T21:57:39Z")

</div>

What type of usersource are you using?

---

<div class="post-metadata">

**Author:** ![tim.schultz](https://avatars.discourse-cdn.com/v4/letter/t/71e660/32.png) [@tim.schultz](https://forum.inductiveautomation.com/u/tim.schultz)\
**Post date:** [February 22, 2022, 10:00pm UTC](https://forum.inductiveautomation.com/t/set-user-properties-through-scripting/56423/4 "2022-02-22T22:00:46Z")

</div>

I’m using an AD\Internal hybrid.

---

<div class="post-metadata">

**Author:** ![tim.schultz](https://avatars.discourse-cdn.com/v4/letter/t/71e660/32.png) [@tim.schultz](https://forum.inductiveautomation.com/u/tim.schultz)\
**Post date:** [February 22, 2022, 10:04pm UTC](https://forum.inductiveautomation.com/t/set-user-properties-through-scripting/56423/5 "2022-02-22T22:04:31Z")

</div>

Issue is resolved - it turns out that that you can only call it from a gateway scope, not from a client script.
