<?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 How can I retrieve the portal user name in a custom WAB widget? in ArcGIS Web AppBuilder Questions</title>
    <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/how-can-i-retrieve-the-portal-user-name-in-a/m-p/618497#M16350</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm building a custom widget in WAB.&amp;nbsp; I need to retrieve the user name of the user logged into the Portal.&amp;nbsp; Is there a property or function in WAB somewhere that can provide that? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 28 Sep 2015 20:35:34 GMT</pubDate>
    <dc:creator>BenFerguson</dc:creator>
    <dc:date>2015-09-28T20:35:34Z</dc:date>
    <item>
      <title>How can I retrieve the portal user name in a custom WAB widget?</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/how-can-i-retrieve-the-portal-user-name-in-a/m-p/618497#M16350</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm building a custom widget in WAB.&amp;nbsp; I need to retrieve the user name of the user logged into the Portal.&amp;nbsp; Is there a property or function in WAB somewhere that can provide that? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Sep 2015 20:35:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/how-can-i-retrieve-the-portal-user-name-in-a/m-p/618497#M16350</guid>
      <dc:creator>BenFerguson</dc:creator>
      <dc:date>2015-09-28T20:35:34Z</dc:date>
    </item>
    <item>
      <title>Re: How can I retrieve the portal user name in a custom WAB widget?</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/how-can-i-retrieve-the-portal-user-name-in-a/m-p/618498#M16351</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ben,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can define portalUtils in widget and access user through the portal instance:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;define([
&amp;nbsp;&amp;nbsp;&amp;nbsp; 'jimu/BaseWidget',
&amp;nbsp; 'jimu/portalUtils',
&amp;nbsp;&amp;nbsp;&amp;nbsp; 'dojo/_base/declare'
&amp;nbsp; ],
function(BaseWidget, portalUtils, declare) {

...
this.portal = portalUtils.getPortal(this.appConfig.portalUrl);
username = this.portal.user.username;
...&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See also:&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/jsapi/portal.html" rel="nofollow noopener noreferrer" target="_blank"&gt;https://developers.arcgis.com/javascript/jsapi/portal.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/jsapi/portaluser-amd.html" rel="nofollow noopener noreferrer" target="_blank"&gt;https://developers.arcgis.com/javascript/jsapi/portaluser-amd.html&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:25:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/how-can-i-retrieve-the-portal-user-name-in-a/m-p/618498#M16351</guid>
      <dc:creator>HerdisGudbrandsdottir</dc:creator>
      <dc:date>2021-12-12T02:25:36Z</dc:date>
    </item>
    <item>
      <title>Re: How can I retrieve the portal user name in a custom WAB widget?</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/how-can-i-retrieve-the-portal-user-name-in-a/m-p/618499#M16352</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Herdis.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hadn't found the portalUtils.getPortal() function.&amp;nbsp; That is what I needed to get a reference to the portal instance the WAB is using.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I wish WAB was better documented.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Sep 2015 14:45:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/how-can-i-retrieve-the-portal-user-name-in-a/m-p/618499#M16352</guid>
      <dc:creator>BenFerguson</dc:creator>
      <dc:date>2015-09-29T14:45:15Z</dc:date>
    </item>
    <item>
      <title>Re: How can I retrieve the portal user name in a custom WAB widget?</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/how-can-i-retrieve-the-portal-user-name-in-a/m-p/618500#M16353</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does this work for in-panel widgets?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Nov 2016 19:16:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/how-can-i-retrieve-the-portal-user-name-in-a/m-p/618500#M16353</guid>
      <dc:creator>Alexwang</dc:creator>
      <dc:date>2016-11-10T19:16:25Z</dc:date>
    </item>
    <item>
      <title>Re: How can I retrieve the portal user name in a custom WAB widget?</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/how-can-i-retrieve-the-portal-user-name-in-a/m-p/618501#M16354</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am getting a: " Uncaught TypeError: Cannot read property 'portalUrl' of undefined " error when I use this code. When I don't have this code, my template loads correctly without any errors and I do have the correct portalUrl in place??&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 08 Jan 2018 14:42:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/how-can-i-retrieve-the-portal-user-name-in-a/m-p/618501#M16354</guid>
      <dc:creator>MansiShah</dc:creator>
      <dc:date>2018-01-08T14:42:33Z</dc:date>
    </item>
    <item>
      <title>Re: How can I retrieve the portal user name in a custom WAB widget?</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/how-can-i-retrieve-the-portal-user-name-in-a/m-p/618502#M16355</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;did you ever figure this out?&amp;nbsp; having the same issue.&amp;nbsp; sometimes i think people find it funny to post incomplete examples instead or withhold which version of the api they are using.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 May 2020 01:28:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/how-can-i-retrieve-the-portal-user-name-in-a/m-p/618502#M16355</guid>
      <dc:creator>NathanB</dc:creator>
      <dc:date>2020-05-28T01:28:21Z</dc:date>
    </item>
    <item>
      <title>Re: How can I retrieve the portal user name in a custom WAB widget?</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/how-can-i-retrieve-the-portal-user-name-in-a/m-p/618503#M16356</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I can't say how much has changed in five years - but I suggest you to debug it by looking into the properties of 'this' in this.appConfig.portalUrl - since the error message implies that appConfig is null - maybe this has changed since 2015? Or maybe the 'this' in your script point to something else? Anyway, good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 May 2020 07:53:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/how-can-i-retrieve-the-portal-user-name-in-a/m-p/618503#M16356</guid>
      <dc:creator>HerdisGudbrandsdottir</dc:creator>
      <dc:date>2020-05-28T07:53:29Z</dc:date>
    </item>
  </channel>
</rss>

