- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2018 12:37 AM
Hi All,
I want to auto populate "asset_tag" value from asset table(alm_hardware) for selected user "requested_for" in service request. Could you please provide me the sample code to achieve this.
Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2018 04:01 AM
Hi Josmad,
The field you are trying to set is a reference field right? or it is a string field.
If it is a reference field it can hold only 1 value
if it is a string field then do you want to populate all the asset tags with comma separated in that field.
If yes then update script as below
getDetails: function(){
var arr = [];
var sysId =this.getParameter('sysparm_sysId');
var gr = new GlideRecord('alm_hardware');
gr.addQuery('assigned_to', sysId);
gr.query();
while(gr.next()){
arr.push(gr.asset_tag.toString());
}
if(arr.length > 0)
return arr.toString();
else
return '';
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2024 01:06 AM
@Ankur Bawiskar i have posted a new query, can you please help me out?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2024 02:45 AM
Did you tag me in the new question? I couldn't see anything.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader