- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2023 04:49 AM
Hi,
I have the variable 'computer name' of type string in my 'create incident' record producer. I have the field 'u_computer_name' of type string on sys_user table. How can I set the default value of this variable inside the record producer to be like computer_name of the current login user when loading the record producer?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2023 05:30 AM
Hi @Alon Grod ,
You need to write an Client Script + Script Include to achieve this
Do as something like this onLoad
Client Script
function onLoad() {
var ga = new GlideAjax('loggedUserData');
ga.addParam('sysparm_name', 'name');
ga.getXML(callback);
}
function callback(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
//put this answer in your variable
}
In Script Include
var loggedUserData= Class.create();
loggedUserData.prototype = Object.extendsObject(AbstractAjaxProcessor, {
name: function () {
return gs.getUser().u_computer_name;
}
});
Please mark correct if my response has solved your query.
Cheers,
Mohammed Basheer Ahmed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2023 07:01 AM
this should work fine
javascript: gs.getUser().getRecord().getValue('u_computer_name');
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2023 02:58 AM
Can you post a new question and tag me there as this is quite older thread?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2024 12:57 PM
Is it posible to write some kind of logic in this type of statements. For example
requested for’s Business phone is the default value and if empty then Mobile phone is the default value and if empty then leave field empty
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2023 08:30 AM
If my response helped please mark it correct and close the thread .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2023 06:52 AM
Utah has a new feature where you can set a variable based on another variable. There's a new section on the Variable form called "Auto-populate". Select the Dependent Question (must be a reference field) and then the "Dot walk path" field allows you to select a data point. In this case, I have selected to pull in the Manager of the Requested For user:
Now, anytime the Requested For variable changes, the Manager variable will stay in sync. If the Requested For user does not have a manager, the Manager variable is cleared.
From the Utah Service Catalog release notes:
Auto-populate a variable based on a reference type variable on the form
Define a relationship between two questions in Catalog Builder (for example, fields such as Requested for and Manager) without the need to script. The value of the dependent question is auto-populated when the value of the initial question is selected or changed.