How to create a UI Page with choice field having value based on the assignment group ?

Rahul Dev1
Giga Expert

I want to create a UI page which will be having a choice field and it should pop when Ui action is clicked.

On the incident form when assignment group is selected , the UI page should have choice value based on that .

I have a different table where the assignment group and its value is stored. I want this value to be mapped to UI page when assignment group is selected on incident form.

How can I achieve this??

Please help!!

 

Thanks,

Rahul

 

 

1 ACCEPTED SOLUTION

Hi,

it seems you are adding the options from client script of UI page

But the link I shared relates to your question and you can create options based on iteration

Something like this

<g:evaluate var="jvar_gr" object="true">
	var arr = ['1','2','3'];
	arr;
</g:evaluate>

<select>
	<j:forEach items="${jvar_gr}" var="jvar_val">                             
		<option value="${jvar_val}">${jvar_val}</option>
	</j:forEach>
</select>

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

in the UI page HTML you can use g:evaluate tag and get all the choices stored in an array and then use j:forEach to iterate over that array

this link has solution which I shared 2 years ago; enhance it for your requirement

how to add choice options from another table dynamically on an ui page

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi @Ankur Bawiskar 

In the <g:evaluate> tag I have got the values inserted into array . Now how can I use that array to add values as an option to my dropdown .

In client script I tried like this  but it is showing wrong values in dropdown:

var selectitem = document.getElementById("component_choice");
var myValues = document.getElementById("componentChoices");
alert(myValues);
for(var i in myValues){
var option = document.createElement("option");
option.text = i;
option.value = myValues[i];
selectitem.add(option);
}

Hi,

it seems you are adding the options from client script of UI page

But the link I shared relates to your question and you can create options based on iteration

Something like this

<g:evaluate var="jvar_gr" object="true">
	var arr = ['1','2','3'];
	arr;
</g:evaluate>

<select>
	<j:forEach items="${jvar_gr}" var="jvar_val">                             
		<option value="${jvar_val}">${jvar_val}</option>
	</j:forEach>
</select>

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Rahul Dev 

Thank you for marking my response as helpful.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader