Need to add a condition Relationships for Related List

venugopal s
Tera Contributor

Hi Everyone,

I need to update a condition on Relationships, Where 

  • Need to update the query to filter only for Personal Computer:

    • model_category=451c87f6db41e2407be67bec0f96193a

    • Applies to Table - Hardware

    • Queries from table  - sys_email

      Script:

      (function refineQuery(current, parent) {

       

          current.addQuery('instance', parent.sys_id);

       

      })(current, parent);
       

 

1 ACCEPTED SOLUTION

@venugopal s 

 

try this, 

function onLoad() {

    var ModalCat = g_form.getValue('model_category');

    if (ModalCat != '451c87f6db41e2407be67bec0f96193a') {
        g_form.hideRelatedList('REL:48c2c2f9977fb110fea876d11153af0c');
    }
}

 

View solution in original post

5 REPLIES 5

Siddhesh Gawade
Mega Sage
Mega Sage

Hello @venugopal s ,

 

Your query looks correct, make sure you are using alm_hardware table, instead of cmdb_ci_hardware table.

 

For the model_category=451c87f6db41e2407be67bec0f96193a , Do you only want show the related list when the this condtion satisfied? Please give more clarification.

 

Regards,

Siddhesh

@venugopal s ,

 

So you can write a onload client script hardware table as below.

SiddheshGawade_0-1706546536414.png

function onLoad() {

   var ModalCat = g_form.getValue('model_category');

   if(ModalCat != '451c87f6db41e2407be67bec0f96193a'){   
	// Use below format for hiding the related list REL:sys_id of relationship record.

   g_form.hideRelatedList('REL:07d38bd547000210a0c8d24b116d4323');
   }
}

 

Kindly mark the answer ✔️ Correct or Helpful ✔️ If it addresses your concern.


Regards,

Siddhesh

venugopal s
Tera Contributor

Hi @Siddhesh Gawade ,

not working

function onLoad() {

    var ModalCat = g_form.getValue('model_category');

    if (ModalCat != '451c87f6db41e2407be67bec0f96193a') {
        g_form.hideRelatedList('48c2c2f9977fb110fea876d11153af0c');
    }
}