Query in client script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2018 02:47 AM
Hi
I have an onchange client script which auto fills fields depending on the person who is logged in and what catergerys are seleceted:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (g_form.getValue('u_subcategory') == 'New' && g_form.getValue('u_category') == 'Certificate') {
g_form.setValue('u_requested_by',g_user.userID) ;
g_form.setValue('short_description','New Certificate Request');
g_form.setValue('description','Certificate name:\r\nCertificate Type (SSL, SSL with EV, Wildcard, Code signing):\r\nCertificate Term:\r\nServer Software:\r\nRegion if applicable (EMEA, ASPAC,US etc)\n\n');
}
I have got it to fill in a field depending on the user (g_user.userID) but I would also like it to fill in the users manager. I dont beleive I can use g_user for this and have to query the sys_user table? I am new to scripting and im not sure how I would encorperate a query into this script.
Any suggestions would be much appreciated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2018 05:57 AM
yes, at the end of script include,it should be
if (user){
return user.manager.toString();// returns manager's sys_id
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2018 06:15 AM
Ok, I dont even get 'null' with this one. Just a blank alert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2018 06:22 AM
update script include
user.get('user_name',id);
as
user.get('sys_id',id);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2018 06:31 AM
Ahah! we now have a sysID coming up in the message box?
How do we get that converted into a name and added to a field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-20-2018 06:37 AM
field is reference or string field.
If string, then update the script include to return name
return user.manager.name.toString();
if reference, then you can set the sys_id itself
