- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-01-2016 03:52 AM
Hi everyone,
I've created a record producer that's using the sc_cat_item view which obviously has some limitations in what is and isn't supported in comparison to the traditional record producer view.
I'm trying to create some variables that are saved to the sys_user table and then auto-display for the users the next time they open the form (based on feedback, saving them time from having to add the same information each time).
I've got a script within the record producer that saves this data to the associated sys_user fields I've previously added:
Here's an example of the completed sys_user fields:
The problem is that my record producer isn't auto-displaying these custom fields (it does work for the display name, phone number and email address though)
I'm really stuck. Any idea?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2016 02:47 AM
From this last screenshot, it seems that you might want to use this:
gs.getUser().getRecord().getValue('utas_building');
Try once, if that works.
If it doesn't, please give a screenshot of your 'sys_user' table columns and labels.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2016 02:42 AM
It should work. Just make sure:
1. You are using correct 'fieldname' and not label.
2. These fields(u_building etc.) has some values for the current logged in user.
3. If you have updated these values recently, then that change won't show up as it will use cached record. So, after updating some value in the concerned record, make sure to logout and then login again.
Try these things, it should work. I tried and its working fine for me.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2016 02:47 AM
From this last screenshot, it seems that you might want to use this:
gs.getUser().getRecord().getValue('utas_building');
Try once, if that works.
If it doesn't, please give a screenshot of your 'sys_user' table columns and labels.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2016 03:14 AM
Thanks Deepak - you're a champion. I'll mark your comment as the correct answer.
Do you have any recommendations on how to configure onchange and onload scripts (using the u_building value as the example)
So that whenever the person whose logged in changes the userID then it updates all other details automatically. And perhaps avoids the cache issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2016 03:28 AM
Glad it worked for you.
For onchange thing,
first create a script include as:
Script:
var UserUtil = Class.create();
UserUtil.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getUserDetails: function() {
var gr = new GlideRecord('sys_user');
gr.get(this.getParameter('sysparm_user_id'));
var res = this.newItem('user');
res.setAttribute('phone', gr.phone + '');//Change gr.phone to gr.u_building or gr.utas_building whatever worked for you.
return res;
}
});
Now, create an onChange Catalog client script on 'caller_id'variable as,
Script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('UserUtil');
ga.addParam('sysparm_name', 'getUserDetails')
ga.addParam('sysparm_user_id', g_form.getValue('caller_id'));
ga.getXML(setDetails);
function setDetails(response) {
var result = response.responseXML.getElementsByTagName("user");
g_form.setValue('u_building', result[0].getAttribute('phone'));
alert(result[0].getAttribute('phone'));
}
}
It will work.
Also, you can send as many parameters as you want from Script include and then use them in client script.
Update if you need more help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-02-2016 03:30 AM