<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to query and set user first and last names in Portal in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-query-and-set-user-first-and-last-names-in/m-p/735190#M239</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Why do some user objects in AGOL have firstName and lastName and some do not?&amp;nbsp; I can't find a common thread between these users.&amp;nbsp; In both case their display profile shows both first and last name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is adding the attributes like you suggest the accepted way of fixing this problem?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 30 Aug 2018 18:26:56 GMT</pubDate>
    <dc:creator>SeanSweeney</dc:creator>
    <dc:date>2018-08-30T18:26:56Z</dc:date>
    <item>
      <title>How to query and set user first and last names in Portal</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-query-and-set-user-first-and-last-names-in/m-p/735187#M236</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm new to the ArcGIS Python API and Jupyter Notebooks so I may just be doing something wrong, but I'd like to update users in AGOL with their last names (since auto-register is not adding last names) but even trying to query for first and last names gives the error:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN class="" style="color: #b22b31; font-weight: bold;"&gt;AttributeError&lt;/SPAN&gt;: 'User' object has no attribute 'firstName'&lt;/PRE&gt;&lt;P&gt;This is the code in my notebook:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcgis
from arcgis.gis import GIS
from IPython.display import display
import getpass
password = getpass.getpass("Enter Password: ")
gis = GIS("http://agol.maps.arcgis.com", "Admin User", password)

user_accounts = gis.users.search('',max_users=700)
for a in accounts:
&amp;nbsp;&amp;nbsp;&amp;nbsp;print (a.firstName)
 &amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've tried a bunch of variations on 'firstName', e.g. 'firstname', 'first_name', 'FirstName', 'firstname', etc. but always get the same result.&amp;nbsp; According to sample code on the &lt;A href="https://developers.arcgis.com/python/sample-notebooks/clone-portal-users-groups-and-content/" rel="nofollow noopener noreferrer" target="_blank"&gt;Python API Samples page&lt;/A&gt;, 'firstName' should work. Also according to the API reference, the &lt;A href="https://esri.github.io/arcgis-python-api/apidoc/html/arcgis.gis.toc.html#user" rel="nofollow noopener noreferrer" target="_blank"&gt;User object&lt;/A&gt; should have a 'userdict' object...&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;EM class="" style="color: #2980b9; font-weight: bold; padding-right: 8px;"&gt;class&lt;/EM&gt;&lt;CODE class=""&gt;arcgis.gis.&lt;/CODE&gt;&lt;CODE class=""&gt;User&lt;/CODE&gt;&lt;SPAN class="" style="color: #2980b9; font-weight: bold;"&gt;(&lt;/SPAN&gt;&lt;EM style="color: #2980b9; font-weight: bold;"&gt;gis&lt;/EM&gt;&lt;SPAN style="color: #2980b9; background-color: #e7f2fa; font-weight: bold;"&gt;,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;EM style="color: #2980b9; font-weight: bold;"&gt;username&lt;/EM&gt;&lt;SPAN style="color: #2980b9; background-color: #e7f2fa; font-weight: bold;"&gt;,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;EM style="color: #2980b9; font-weight: bold;"&gt;userdict=None&lt;/EM&gt;&lt;SPAN class="" style="color: #2980b9; font-weight: bold;"&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...but I can't seem to get that either.&amp;nbsp; But maybe I'm reading that wrong?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can resolve and print the username fine, i.e. "print (a.username)", so I know I have valid User objects.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've found online that it isn't until v1.4.1 that we are able to update users with first and last name.&amp;nbsp; I'm not sure what version I'm running locally and also not sure how to find it -- is there a command I can run in Notebook to give me the Python API version number?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried running this same code in the online Jupyter Notebook on the Esri Python API '&lt;A href="https://notebooks.esri.com/user/GXwkwpzY85j1SPrhJAOQPaKGl/notebooks/samples/03_org_administrators/clone_portal_users_groups_and_content.ipynb" rel="nofollow noopener noreferrer" target="_blank"&gt;try it live&lt;/A&gt;' site,which I was hoping is the latest version, but I'm getting the same error there.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any thoughts?&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:20:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-query-and-set-user-first-and-last-names-in/m-p/735187#M236</guid>
      <dc:creator>deactivated-user-ChrisBeaudett</dc:creator>
      <dc:date>2021-12-12T07:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to query and set user first and last names in Portal</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-query-and-set-user-first-and-last-names-in/m-p/735188#M237</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&amp;nbsp;&lt;A href="https://community.esri.com/migrated-users/327534" target="_blank"&gt;Chris Beaudette&lt;/A&gt;&amp;nbsp;-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can find the ArcGIS API for Python version from the Jupyter notebook with the following code:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcgis
arcgis&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;__version__‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If a user doesn't have values for the firstName or lastName attributes, the error you observe is returned.&amp;nbsp; At version 1.4.1, you can use the&amp;nbsp;user.update(first_name='first', last_name='last') function to add that information and then your code would return values.&amp;nbsp; You can get around this by checking for the existence of that attribute:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; user &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; user_accounts&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;try&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;user&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;firstName&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;except&lt;/SPAN&gt; AttributeError&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"{} has no firstName attribute."&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;format&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;user&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;username&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:20:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-query-and-set-user-first-and-last-names-in/m-p/735188#M237</guid>
      <dc:creator>JohnYaist1</dc:creator>
      <dc:date>2021-12-12T07:20:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to query and set user first and last names in Portal</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-query-and-set-user-first-and-last-names-in/m-p/735189#M238</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is exactly what I needed.&amp;nbsp; Thanks &lt;A href="https://community.esri.com/migrated-users/71278"&gt;John Yaist&lt;/A&gt;‌!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 31 May 2018 00:26:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-query-and-set-user-first-and-last-names-in/m-p/735189#M238</guid>
      <dc:creator>deactivated-user-ChrisBeaudett</dc:creator>
      <dc:date>2018-05-31T00:26:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to query and set user first and last names in Portal</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-query-and-set-user-first-and-last-names-in/m-p/735190#M239</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Why do some user objects in AGOL have firstName and lastName and some do not?&amp;nbsp; I can't find a common thread between these users.&amp;nbsp; In both case their display profile shows both first and last name.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is adding the attributes like you suggest the accepted way of fixing this problem?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 30 Aug 2018 18:26:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/how-to-query-and-set-user-first-and-last-names-in/m-p/735190#M239</guid>
      <dc:creator>SeanSweeney</dc:creator>
      <dc:date>2018-08-30T18:26:56Z</dc:date>
    </item>
  </channel>
</rss>

