- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2023 02:37 AM
can you try setting the name attribute with the filter condition?
<g:ui_reference_multi id="multi" name="multi" table="sys_choice" name="name=u_hiring_plan_availability_hours^element=u_month" query="name=u_hiring_plan_availability_hours^element=u_month" coloumns="label" onChange="onMonthChange(e)"/>
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2023 03:16 AM
@Ankur Bawiskar Nope didnt work.
Could you please help me set the filter in the client script.
Depending on the year user choose, I can obtain a list of all the sys_ids for the months that apply to that year. I am unable to set the filter in the client script, though.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2023 04:05 AM
can you try this?
var YearLookUp = gel('lookup.multi'); //document.getElementById("multi") //gel('lookup.multi');
YearLookUp.setAttribute('onclick',"mousePositionSave(event); reflistOpen( 'multi', 'not', 'sys_choice', '', 'false','QUERY:inactive=false','sys_idIN" + userArray+ "', '')");
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2023 04:23 AM - edited 08-01-2023 04:31 AM
@Ankur Bawiskar I am not using g:ui_referene ui macro since I am using g:ui_reference_multi ui macro below is not working
YearLookUp.setAttribute('onclick',"mousePositionSave(event); reflistOpen( 'multi', 'not', 'sys_choice', '', 'false','QUERY:inactive=false','sys_idIN" + userArray+ "', '')");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2023 06:14 AM
I hope this helps -
<g:ui_reference_multi id="multi" name="multi" table="sys_choice" reference="sys_choice" columns="label" onchange="onMonthChange()"/>
Client Script -
function onMonthChange() {
var answer = g_form.getValue('your_other_field'); // Replace 'your_other_field' with the actual field name that holds the value to be used for the query
var mnthsArr = JSON.parse(answer);
var userArray = [];
// Query the 'sys_choice' table on the client-side to get the sys_ids for the months based on the selected date
var gmAud = new GlideRecord('sys_choice');
gmAud.addQuery('name', 'u_hiring_plan_availability_hours');
gmAud.addQuery('element', 'u_month');
gmAud.addQuery('value', mnthsArr[0]);
gmAud.query();
while (gmAud.next()) {
if (userArray.indexOf(gmAud.sys_id.toString()) === -1)
userArray.push(gmAud.sys_id.toString());
}
// Get the reference field element
var referenceField = document.getElementById('multi');
// Set the reference attribute on the g:ui_reference_multi macro with the dynamic query
referenceField.setAttribute('reference', 'sys_choice'); // Set the table name for the reference field
referenceField.setAttribute('query', "active=true^sys_idIN" + userArray.join(',')); // Set the dynamic query based on the selected date
}
Please, don't forget to mark my answer as correct if it solves your issue or mark it as helpful if it is relevant for you!
Regards,
Tushar