Hello community,
I am currently building an ArcGIS Experience Builder application and I would like to be able to add a header where the person viewing the application with a connected ArcGIS account can see a message like "Hello, Franck". But I don't know how to get the user's first name or nickname and how to integrate it into a Text widget or elsewhere.
Can you help me ?
Have a nice day.
Solved! Go to Solution.
It might be as simple as adding a question mark to this line.
<div className='center'>
{props.user?.firstName &&
<span><p>Bonjour {props.user.firstName}</p></span>
}
</div>
You could also try a teriary.
<div className='center'>
{props.user ?
<span><p>Bonjour {props.user.firstName}</p></span> : <></>
}
</div>
The next thing to try after that is to use your useEffect statement to put the username into state.
Hi @JeffreyThompson2 it works with your first advice, big thanks 🙂
Hello !
Can I create a little script for this widget (which be simple to write) without using the developer edition ?
I mean, i can't host the application on a webserver because i have not the right. I only want to import a little script to have a custom widget.
Thanks.
There is no way to simply add a few lines of code to Experience Builder without Developer Edition. If you are using a version of ArcGIS Enterprise 11.X, it is possible to connect a custom widget to your portal, but you will still need to host the custom widget on the web somewhere. https://www.esri.com/arcgis-blog/products/arcgis-enterprise/developers/add-experience-builder-custom...
This example hosts the widget on Github Pages which is a simple, free hosting platform for very basic applications.
Oh ! it's gonna be good for me ! Nice !
So if I want to write a javascript for a custom widget to retrieve the username, i have only to use the props.user objects or it's more complicated ? I'm not friendly with javascript.
https://developers.arcgis.com/experience-builder/guide/install-guide/
https://developers.arcgis.com/experience-builder/guide/create-a-starter-widget/
https://docs.github.com/en/get-started/quickstart/set-up-git
Before getting started read over the installation and starter widget guides. You should also look at the GitHub guides if you are going to host there. There is a steep learning curve in the setup process if you are not familiar with programming.
Thanks for the links.
I'm gonna read all of this and try to create the widget after that. U help me very well thank you.
Just as an update for anyone looking for this post 2025: you can do this with smart forms and Arcade.
https://developers.arcgis.com/arcade/function-reference/portal_functions/