- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2023 06:48 AM
Whenever I login in with my user Id the preparer name should be auto populate with my login details.
I have wrote the client script onLoad condition but its not working
function onLoad() {
var currentUser = g_user.userID;
if (g_form.isNewRecord()) {
g_form.setvalue(currentUser,'preparer');
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2023 11:39 PM
Hello,
Its not best practice to use client scripts as they just display value on the form while loading but value is not saved in the database unless user clicks on save or update.
Instead of client script, right click on the 'Preparer' field & configure dictionary & go to default value tab.
Click on dynamic default value & select 'Me'
OR if you can also write this line in default value field 'javascript:gs.getUserID()'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2023 11:48 PM
Hi @TA33 ,
Hope you are doing great.
Firstly , if you want to autopopulate the preparer field as logged in user , then ideally best way is to set default value of field by clicking right click on preparer field and clicking on configure dictionary. There in default value section you can define your default value for field. This is best approach for doing your requirement.
But still if you want to accomplish it by your way by vreating client script:
function onLoad() {
var currentUser = g_user.userID;
if (g_form.isNewRecord()) {
g_form.setValue('preparer', currentUser);
}
}
But this value will be in display only in form, it wont be save in database. If you save the form the value will be saved else it will be lost.
Regards,
Riya Verma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2023 11:39 PM
Hello,
Its not best practice to use client scripts as they just display value on the form while loading but value is not saved in the database unless user clicks on save or update.
Instead of client script, right click on the 'Preparer' field & configure dictionary & go to default value tab.
Click on dynamic default value & select 'Me'
OR if you can also write this line in default value field 'javascript:gs.getUserID()'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-06-2023 03:13 AM
I want to get logged user Email and Manager same like Userid
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-20-2023 11:48 PM
Hi @TA33 ,
Hope you are doing great.
Firstly , if you want to autopopulate the preparer field as logged in user , then ideally best way is to set default value of field by clicking right click on preparer field and clicking on configure dictionary. There in default value section you can define your default value for field. This is best approach for doing your requirement.
But still if you want to accomplish it by your way by vreating client script:
function onLoad() {
var currentUser = g_user.userID;
if (g_form.isNewRecord()) {
g_form.setValue('preparer', currentUser);
}
}
But this value will be in display only in form, it wont be save in database. If you save the form the value will be saved else it will be lost.
Regards,
Riya Verma