Reference Qualifier not working

Lusifer1984
Tera Contributor

Hi 

 

1. I wanted to pass company value dynamically based on value selected in problem from 

Lusifer1984_1-1697745876802.png

 

 

2. I have created a M2M and add to related list 

Lusifer1984_2-1697745985802.png

 

 

Once click on Edit button its showing all values which is part of cmdb_ci_nw_site table 

 

Lusifer1984_3-1697746090941.png

 

But we need to pass the company value  here dynamically from step 1 ( company is nothing but account name ) and under one account name multiple sites are there. Example here I will only able to see if it passes dynamically only like below 

 

Lusifer1984_4-1697746444867.png

 

 

 

How to do that , manually selection of company from Company filter is not acceptable. Any idea how to pass this Dynamically from Problem from to this area based on selected value in the problem from account.

 

Luso

 

 

 

 

5 REPLIES 5

AnveshKumar M
Tera Sage
Tera Sage

Hi @Lusifer1984 

 

You can achieve this using a custom UI Action. Create an UI Action of type list banner (name it as "Edit 1" like that, to differentiate it from the global Edit UI Action) for the table in related list and then in the condition  use the following filter

 

(new GlideRecord(current.getTableName())).canCreate() && RP.isRelatedList() && !RP.getListControl().isOmitEditButton()

 

Then in the scrip field use the following code,

 

var uri = action.getGlideURI();
var path = uri.getFileFromPath();
uri.set('sysparm_m2m_ref', current.getTableName());
uri.set('sysparm_stack', 'no');

//Create query
var query = uri.get('sysparm_query');
if (query){
query = query + '^';

}else{

query = query + "company=" + parent.account_name.toString(); // Here change the company and account_name field names as per your related list table field name and parent table name

}

uri.set('sysparm_query', query);

action.setRedirectURL(uri.toString('sys_m2m_template.do'));

 

Now reload the form and try the Edit 1 button in your related list if it works disable the global Edit button and rename the Edit 1 button to Edit.

 

 

Please mark my answer helpful and accept as solution if it helped you 👍

Thanks,
Anvesh

Hi Avinash,

 

This is not working unfortunately 

 

Lusifer1984_0-1697824876581.png

 

Script

Lusifer1984_1-1697825238246.png

 

 

 

 

 

@Lusifer1984 try this code.

 

var uri = action.getGlideURI();

var path = uri.getFileFromPath();

uri.set('sysparm_m2m_ref', current.getTableName());

uri.set('sysparm_stack', 'no');

 

//Create query

var query = uri.get('sysparm_query');

if (query){

query = query + "^company=" + parent.u_account_name.toString(); // Here change the company and account_name field names as per your related list table field name and parent table name

 

}else{

 

query =  "company=" + parent.u_account_name.toString(); // Here change the company and account_name field names as per your related list table field name and parent table name

 

}

 

uri.set('sysparm_query', query);

 

action.setRedirectURL(uri.toString('sys_m2m_template.do'));

 

Please try this code and let me know.

Thanks,
Anvesh

No Still same is coming.