Default Phone Variable Value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2017 12:53 PM
Hello
Right now, when a user opens a service request, the form auto populates the phone number with the logged in user. I want the phone variable to be based off of the "requested for" variable. How would I go about doing this? Here is the script in the default value for the phone variable.
I'm not sure I'm wanting to actually get the userID? I may be wrong though. Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2017 01:02 PM
you can write an onchange client script on variable name requested for
if(newValue!='')
{
var reqfrm = g_form.getReference('requested_for', phne);
function phne(reqfrm(
{
g_form.setValue('phone',reqfrm.phone);
{
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2017 01:33 PM
Please try this
var ga = new GlideAjax('getUserInfo');
ga.addParam('sysparm_name','userInfo');
ga.addParam('sysparm_user_name',g_form.getValue('requesting_for'));
ga.getXML(parseResponse);
//Return results
function parseResponse(response) {
var result = response.responseXML.getElementsByTagName("result");
var userPhone = result[0].getAttribute("userPhone");
//Load Form with new phone number
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2017 01:38 PM
In the Default Value field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2017 01:41 PM
Use this line of code in your default value section:
javascript:gs.getUser().getRecord().getDisplayValue("phone"); // This set the value of login user by onLoad
if you want populate the user phone number, on change of User you need to write onChange catalog client script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2017 06:04 AM
Balaji,
I'm trying to write the onChange catalog client script. Will I need to delete the default value script from the actual variable also?