Auto Poupulate the asset assigned to the user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2024 01:04 AM
Hi,
I have the catalog form where there are 2 reference fields.
1. user_to_be_released - reference of sys_user table
2. computer_name - reference of alm_hardware table
Now i need to auto populate the asset assigned to the user( "user_to_be_release field") in computer_name field and below are the CS and script include which i have written. But i didnt get any values returned in computer_name field.
Can you please help me with this and is there any reference qualifier needs to added in computer_name field? Please give your suggestions, since i am new to scripting.
Client Script - written on computer_name and type is onChange
Script Include - client callable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2024 01:44 AM
Thanks Jitendra,
Background script is now returning the value. So what should i do next, can you please guide me?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2024 01:51 AM
Hi @Aruna13,
So now you can modify your query as below:
var req = this.getParameter('sysparm_user_to_be_released');
var hardwaretoassignee = '';
var gr = new GlideRecord('alm_hardware');
gr.addQuery('assigned_to', req);
gr.addQuery('model_category','sys_id of model');// always user sys_id and try to avoid query by name
gr.query();
if (gr.next()) {
hardwaretoassignee = gr.assest-tag;
}
return hardwaretoassignee;
Please accept my solution if it works for you and thumps up.
Thanks
Jitendra
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2024 01:57 AM
Hi @Jitendra Diwak1 ,
I modified script include as you suggessted. Dont I have to modify client script which i wrote, can you please check and guide me please.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2024 02:02 AM
Hi @Aruna13,
Please replace this line in client script below:
ga.addParam('sysparm_user_to_be_released', newValue);
and make sure "computer_name' is reference and refer to alm_hardware.
Please accept my solution if it works for you and thumps up.
Thanks
Jitendra
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2024 02:13 AM
I have updated both my CS and Script include as below. But still the computer name is not getting auto populated. PFB screenshots. Please take a look and guide me. Do I have to write a reference qualifier for computer name field, i am not sure.
CS:
Script Include:
Computer_name variable: