form to ui page

Yahav Mor
Tera Contributor

Hi all 
I need to take from  the form in INCIDENT the value in the field  assignment_grou and put the value inside the html in  ui page  (i have ui action between them )

How can i take from the field and put it in HTML ?

 

 

 

6 REPLIES 6

Amit Gujarathi
Giga Sage
Giga Sage

HI @Yahav Mor  ,
I trust you are doing great.

To retrieve the value from the "assignment_group" field in the INCIDENT form and place it inside the HTML code in a UI page, you can follow these steps:

  1. Identify the UI page where you want to display the value from the "assignment_group" field.
  2. Add a UI action to the relevant UI page. This UI action will be responsible for retrieving the field value and updating the HTML code.
  3. Define the UI action script. Here's an example script that you can modify according to your specific requirements:

 

// Get the assignment group field value from the current incident record
var assignmentGroup = g_form.getValue('assignment_group');

// Modify the HTML code on the UI page to include the assignment group value
var htmlElement = document.getElementById('your-html-element-id'); // Replace 'your-html-element-id' with the actual ID of the HTML element in your UI page
htmlElement.innerHTML = assignmentGroup;

 

  • Save the UI action script and ensure it's associated with the desired UI page.

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



Ankur Bawiskar
Tera Patron
Tera Patron

@Yahav Mor  

can you share what script have you tried so far?

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

Yahav Mor
Tera Contributor

ui action :

function openUIPage() {
var assignmentGroup = g_form.getValue('assignment_group');
var dialog = new GlideDialogWindow('testassignedto');
dialog.setTitle('USER');
dialog.setSize(450, 150);
dialog.adjustBodySize();
dialog.render();
}

UI PAGE HTML
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<table>

<g:ui_form>
<g:evaluate jelly="true" object="true" var="jvar_kparticles">
var htmlElement = document.getElementById('assignment_group');
           htmlElement.innerHTML = assignmentGroup;
var kb = new GlideRecord('sys_user_grmember');
kb.addQuery('group',assignmentGroup);
var list = [];
           kb.query();
         while(kb.next()){
list.push(kb.getValue('user')); }
list.toString();
</g:evaluate>
<g:ui_reference name="assigned_to" id="assigned_to" table="sys_user" query="sys_idIN${jvar_kbarticles}" completer="AJAXTableCompleter" />


<div class="col-sm-9" style="margin-top:9px">
<button id="cancel_button" class="bth bth-default" onclick="onCancel()" type="button" style="margin-right:spx">
${gs.getMessage('cancel')} </button>
<button id="ok_button" class="bth bth-destructive" onclick="OK()" type="button" >
${gs.getMessage('ok')} </button>
</div>
</g:ui_form>
</table>
</j

@Yahav Mor  

okay you want to show only those users in assigned to who are member of that group on form?

I shared solution for similar requirement few days ago. check that and enhance it

how to select users only part of that assignment group of that selected record in ui page 

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

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