Incident form customized filed auto population of user details
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2024 06:18 PM
Hi Team
i have created a custom filed on incident form back end name :(u_t_id), i want to auto populate the user details on customized filed
i have used on load client script , but it is not working
// Get the user ID from the current user var userId = g_user.userID; // Set the caller_id field with the user ID g_form.setValue("caller_id", userId); // Get the reference record for the caller_id field var callerId = g_form.getReference("caller_id"); // Get the username from the reference record and set u_t_id field if (callerId) { var username = callerId.username; g_form.setValue("u_t_id", username); }
Regards
khasim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2024 07:22 AM
Hi @khasim523169 ,
Modified a bit. Try once.
// Get the user ID from the current user
var userId = g_user.userID;
g_form.setValue('caller_id',userId);
// Get the reference record for the caller_id field
var callerId = g_form.getReference("caller_id", setUTID);
// Callback function to handle the reference record
function setUTID(callerId) {
var username = callerId.user_name; // Adjust this line based on your user structure
alert(username);
g_form.setValue("short_description", username);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2024 08:46 AM
Incident already have caller field , any reason to create another field and get value?
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2024 07:51 AM
Dear Atul
i am just trying , is it possible to set the user details in customs filed (which was created by user).. through client script
Regards
khasim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2024 09:29 AM
Yes, why not. Use scripts and work done buddy.
Keep Learning N Keep Growing.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************