Reference field dependency in UI Page

Shankar Manohar
Mega Guru

Greetings Everyone!

  I have   a catalog item and have a classification Field( Variable) which is reference to custom table ( Classification). I have created a UI page in my Catalog Item with Group Roles and User ID.

  Now, the Group Role is reference to Custom Table ( Group) which has Group Roles tagged to Classification above ( Only two Classification, A & B).

Now, My requirement is If I choose A in my Classification Field,Only the roles tagged to A should be listed in my Group Role Field and If Chosen B, the roles that are tagged to B should be listed in my Group Role reference field.

    I have tried different option but no luck. Please let me know if there is something way we can achieve my requirement.

$5B313F746E4BCC9B.jpg

My HTML Code:

                    <TD><g:ui_reference name="group_role" query="u_classification=u_pgm_classification.value" id="Group_Role" table="u_pgm_group_role" completer="AJAXTableCompleter" columns="u_group_role" /></TD>                                                

              <TD><g:ui_reference name="ln_user" query="active=true^u_employee_type=SAPHR" id="ln_user" table="sys_user" completer="AJAXTableCompleter" columns="user_name" /></TD>

Corresponding Client Script:

var root = document.getElementById(r);

      var allRows = root.getElementsByTagName('tr');

      var cRow = allRows[1].cloneNode(true);

      var j = 0;

      for (j = 0; j < cRow.cells.length; j++) {

              if(j>0 && j!=4){

                      document.getElementById('fn_user').value = '';

                      document.getElementById('sys_display.fn_user').value = '';

                      document.getElementById('ln_user').value = '';

                      document.getElementById('ln_user').name = '';

                      document.getElementById('sys_display.ln_user').value = '';

              }

      }

      root.appendChild(cRow);

}

function deleteRow(r) {

      try {

              var table = document.getElementById(r);

              var rowCount = table.rows.length;

             

              for(var i=0; i<rowCount; i++) {

                      var row = table.rows[i];

                      var chkbox = row.cells[0].childNodes[0];

                      if(rowCount>2){

                              if(null != chkbox && true == chkbox.checked) {

                                      table.deleteRow(i);

                                      rowCount--;

                                      i--;

                              }

                      }

              }

      }

      catch(e) {

              alert(e);

      }

}

1 ACCEPTED SOLUTION

Hi Ankur,



Apologies for the delay in response. I tried in my personal instance and its not working as expected. Would you be able to check mine if I share my creds?



Pls confirm. I will mail the details..



Thanks


Shan


View solution in original post

15 REPLIES 15

Shankar Manohar
Mega Guru

Hi Ankur,



  Will test the above code and update the result at the earliest.



Thanks


Shankar


Hi Shankar,



Any update on this?



Mark Correct if this solves your issue and also hit Like and Helpful if you find my response worthy based on the impact.


Thanks


Ankur


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

Hi Shankar,



Any update on this?


Can you mark my answer as correct, helpful and hit like if you were able to achieve the requirement. This helps in removing this question from unanswered list and helps users to learn from your thread. Thanks in advance.



Regards


Ankur


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

Hi Ankur,



Apologies for the delay in response. I tried in my personal instance and its not working as expected. Would you be able to check mine if I share my creds?



Pls confirm. I will mail the details..



Thanks


Shan


Hi Shankar,



If you have followed the steps I mentioned it should work and there should not be any issue.


just check the code again.



Regards


Ankur


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