# Get the User Source the project is set to in perspective

**URL:** <https://forum.inductiveautomation.com/t/get-the-user-source-the-project-is-set-to-in-perspective/58979>\
**Category:** Ignition\
**Created:** [April 28, 2022, 11:33am UTC](https://forum.inductiveautomation.com/t/get-the-user-source-the-project-is-set-to-in-perspective/58979 "2022-04-28T11:33:05Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![user66](https://avatars.discourse-cdn.com/v4/letter/u/b487fb/32.png) [@user66](https://forum.inductiveautomation.com/u/user66)\
**Post date:** [April 28, 2022, 11:33am UTC](https://forum.inductiveautomation.com/t/get-the-user-source-the-project-is-set-to-in-perspective/58979/1 "2022-04-28T11:33:05Z")

</div>

Is there a way by which I can know which user source the project is using.

This is to add user using script to the user source which the project is currently set to.  
If there is any change of user source then user should be added to that user source.  
i.e.  
`system.user.addUser(` `"AcmeWest"` `, userToGet)`

I want a variable to be used instead of “AcmeWest”

---

<div class="post-metadata">

**Author:** ![andreas](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/andreas/32/18981_2.png) [@andreas](https://forum.inductiveautomation.com/u/andreas)\
**Post date:** [April 29, 2022, 6:51am UTC](https://forum.inductiveautomation.com/t/get-the-user-source-the-project-is-set-to-in-perspective/58979/2 "2022-04-29T06:51:43Z")

</div>

Like this? 🙂

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/9/a94ca594bb3a70fb12b755050078593d3449bdd7.png)

---

<div class="post-metadata">

**Author:** ![user66](https://avatars.discourse-cdn.com/v4/letter/u/b487fb/32.png) [@user66](https://forum.inductiveautomation.com/u/user66)\
**Post date:** [April 29, 2022, 7:27am UTC](https://forum.inductiveautomation.com/t/get-the-user-source-the-project-is-set-to-in-perspective/58979/3 "2022-04-29T07:27:04Z")

</div>

I tried this. But it doesn’t seem to work in perspective  
When I tired to bind this to a parameter in a view it gives me error “Bad\_Notfound”

---

<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:** [April 29, 2022, 7:37am UTC](https://forum.inductiveautomation.com/t/get-the-user-source-the-project-is-set-to-in-perspective/58979/4 "2022-04-29T07:37:17Z")

</div>

- Parameters

String userSource - The user source to add a user to. **If set to an empty string, the function will attempt to use the project’s default user source** (if called from a project).

---

<div class="post-metadata">

**Author:** ![andreas](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/andreas/32/18981_2.png) [@andreas](https://forum.inductiveautomation.com/u/andreas)\
**Post date:** [April 29, 2022, 7:37am UTC](https://forum.inductiveautomation.com/t/get-the-user-source-the-project-is-set-to-in-perspective/58979/5 "2022-04-29T07:37:19Z")

</div>

Ah, perspective, how did I miss that…

---

<div class="post-metadata">

**Author:** ![user66](https://avatars.discourse-cdn.com/v4/letter/u/b487fb/32.png) [@user66](https://forum.inductiveautomation.com/u/user66)\
**Post date:** [April 29, 2022, 7:46am UTC](https://forum.inductiveautomation.com/t/get-the-user-source-the-project-is-set-to-in-perspective/58979/6 "2022-04-29T07:46:07Z")

</div>

😅 np

---

<div class="post-metadata">

**Author:** ![user66](https://avatars.discourse-cdn.com/v4/letter/u/b487fb/32.png) [@user66](https://forum.inductiveautomation.com/u/user66)\
**Post date:** [April 29, 2022, 9:25am UTC](https://forum.inductiveautomation.com/t/get-the-user-source-the-project-is-set-to-in-perspective/58979/7 "2022-04-29T09:25:40Z")

</div>

> [@victordcq](#):
>
> String userSource - The user source to add a user to. **If set to an empty string, the function will attempt to use the project’s default user source** (if called from a project).

This doesn't seem to work although no error occurred

---

<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:** [April 29, 2022, 9:56am UTC](https://forum.inductiveautomation.com/t/get-the-user-source-the-project-is-set-to-in-perspective/58979/8 "2022-04-29T09:56:02Z")

</div>

you also have to provide an empty string in the getNewUser()

this worked for me

```auto
userToGet = system.user.getNewUser("", "mTrejo")
  
# Add some contact info.
contactInfo = {"email":"mTrejo@acmewest.com","sms": "5551234"}
userToGet.addContactInfo(contactInfo)
userToGet.set("password", "thisIsMyPassword")
  
# Adds a user to the the AcmeWest usersource.
system.user.addUser("", userToGet)

```

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/9/a953ccfe52803d5a516f9ad8ef527f8098b2f887.png)

---

<div class="post-metadata">

**Author:** ![user66](https://avatars.discourse-cdn.com/v4/letter/u/b487fb/32.png) [@user66](https://forum.inductiveautomation.com/u/user66)\
**Post date:** [April 29, 2022, 10:07am UTC](https://forum.inductiveautomation.com/t/get-the-user-source-the-project-is-set-to-in-perspective/58979/9 "2022-04-29T10:07:42Z")

</div>

Thanks for that.  
Yes I did the same.  
But it’s not working 🤔.

The user source is set in project properties\>general right?

---

<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:** [April 29, 2022, 10:26am UTC](https://forum.inductiveautomation.com/t/get-the-user-source-the-project-is-set-to-in-perspective/58979/10 "2022-04-29T10:26:04Z")

</div>

Yes that is correct

> [@victordcq](#):
>
> (if called from a project).

Are you calling the script from the project? (a button event)

---

<div class="post-metadata">

**Author:** ![user66](https://avatars.discourse-cdn.com/v4/letter/u/b487fb/32.png) [@user66](https://forum.inductiveautomation.com/u/user66)\
**Post date:** [April 29, 2022, 10:30am UTC](https://forum.inductiveautomation.com/t/get-the-user-source-the-project-is-set-to-in-perspective/58979/11 "2022-04-29T10:30:26Z")

</div>

> [@victordcq](#):
>
> Are you calling the script from the project? (a button event)

Yes. I'm calling it on click of a button.

Also `system.user.getUsers()` does not take null string as an argument  
Hence, I'm not able to iterate through all the users in the usersource and check if there already exits an user with same Email ID that I'm about to add.

---

<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:** [April 29, 2022, 10:33am UTC](https://forum.inductiveautomation.com/t/get-the-user-source-the-project-is-set-to-in-perspective/58979/12 "2022-04-29T10:33:27Z")

</div>

its not null its `""`

The example in the docs is this:  
[https://docs.inductiveautomation.com/display/DOC81/system.user.getUsers](https://docs.inductiveautomation.com/display/DOC81/system.user.getUsers)  
Code Snippet  
This example will print the first and last name of all users, **using the default datasource**.

```auto
users = system.user.getUsers("")
for user in users:
   print user.get('firstname') + " " + user.get('lastname')

```

---

<div class="post-metadata">

**Author:** ![user66](https://avatars.discourse-cdn.com/v4/letter/u/b487fb/32.png) [@user66](https://forum.inductiveautomation.com/u/user66)\
**Post date:** [April 29, 2022, 10:40am UTC](https://forum.inductiveautomation.com/t/get-the-user-source-the-project-is-set-to-in-perspective/58979/13 "2022-04-29T10:40:53Z")

</div>

Yes I used “” 🥲

Must be something related to the version of ignition I’m using

---

<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:** [April 29, 2022, 10:50am UTC](https://forum.inductiveautomation.com/t/get-the-user-source-the-project-is-set-to-in-perspective/58979/14 "2022-04-29T10:50:41Z")

</div>

What version is that then?

---

<div class="post-metadata">

**Author:** ![user66](https://avatars.discourse-cdn.com/v4/letter/u/b487fb/32.png) [@user66](https://forum.inductiveautomation.com/u/user66)\
**Post date:** [April 29, 2022, 11:43am UTC](https://forum.inductiveautomation.com/t/get-the-user-source-the-project-is-set-to-in-perspective/58979/15 "2022-04-29T11:43:44Z")

</div>

I’m using 8.1.7

---

<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:** [April 29, 2022, 12:52pm UTC](https://forum.inductiveautomation.com/t/get-the-user-source-the-project-is-set-to-in-perspective/58979/16 "2022-04-29T12:52:58Z")

</div>

try upgrading then i guess

---

<div class="post-metadata">

**Author:** ![user66](https://avatars.discourse-cdn.com/v4/letter/u/b487fb/32.png) [@user66](https://forum.inductiveautomation.com/u/user66)\
**Post date:** [April 29, 2022, 1:36pm UTC](https://forum.inductiveautomation.com/t/get-the-user-source-the-project-is-set-to-in-perspective/58979/17 "2022-04-29T13:36:08Z")

</div>

yes trying that
