Auto Populate Current User First and Last name ( String ) in scoped App
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2024 04:55 AM
I created an Employee Entry form in a scoped app, Created First and Last name ( String ) field, would like to auto populate the first and last name of the current user. Can some one help me with the script for the scoped app
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2024 06:07 AM
Hi @Raj23 ,
You can write a onLoad Client script using g_form API, I've provided the code below:
Feel free to customize the code according to you:
(function executeRule(current, previous /*null when async*/) {
// Ensure we are in a scoped application
if (typeof g_user !== 'undefined') {
// Retrieve the first name and last name of the current user
var firstName = g_user.firstName;
var lastName = g_user.lastName;
// Set the field values
g_form.setValue('first_name', firstName);
g_form.setValue('last_name', lastName);
}
})(current, previous);
Thanks.
Hope it helps.
If my response turns useful mark it helpful and accept solution😊.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2024 06:11 AM
Another option is to do this within the dictionar entries' default value field.
javascript: gs.getUser(). getFirstName()
javascript: gs.getUser(). getLastName()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2024 11:48 PM
I tried the same for Department field in the form but didn't had the same behavior.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-08-2024 08:28 AM
The syntax in your screenshot doesn't look correct, it should be colon ":" after the word javascript, not a semicolon ";"