Jelly While Tag - how we can set a Value for a Button and use it in the Clientscript

Meloper
Kilo Sage

If i use this:

<g:evaluate var="jvar_myvar" jelly="true" object="true">

var inc = new GlideRecord('incident');
inc.setLimit('5');
inc.addQuery('active' , 'true');
inc.query();

inc;
</g:evaluate>


<j:while test="${jvar_myvar.next()}">
<button>${jvar_myvar.getValue('number')}</button>
</j:while>

i am able to create a Button for each GlideRecord Element.

Now i need a Solution to give that Buttons a Value and use this Value in the CS.

 

For Example:

I have 5 Buttons with there Incident Numbers.

Each Numbers should also be the Value of each Button

And if i click on one of these Button, the Value should be written in a Field on the Incident Form.

 

find_real_file.png
Without the Value, the Button appears with the Groupname (its another example)

1 ACCEPTED SOLUTION

I think the issue may be elsewhere... Let me take a jab now.

Replace your button code with this:

<button type="button" onclick="updateField('${jvar_group_buttons.getValue('sys_id')}')">${jvar_group_buttons.getDisplayValue('group')}</button>

 

The assignment group is a reference field and only loves sysid.

 

Edit : ADDED THE TYPE ATTRIBUTE TO THE BUTTON and changed value to sys id

 

This should work!

View solution in original post

9 REPLIES 9

AnirudhKumar
Mega Sage
Mega Sage

Ha! Found you again!

In your screenshot, line 37, use quotes for the value attribute.

value="${jvar_group_buttons.getDisplayValue('group')}"

And rather than holding the value in the "value" attribute , you could directly pass it to your client script:

<button onclick="updateField('${jvar_group_buttons.getDisplayValue('group')}')">${jvar_group_buttons.getDisplayValue('group')}</button>

 

find_real_file.png

 

Alert works fine!

Line 5 work also, but after the Value appears in the Field for 2 Seconds, 

the INC Form disappears and the generated button stands alone at the top of the frame

Hmm... Could you tell me how you are calling your UI page?

and also the start to end of what you are trying to do...