The CreatorCon Call for Content is officially open! Get started here.

Script Include, Client Script

Nipan1
Tera Contributor

Hi,

 

I have a requirement as below.

 

1. There are 2 fields (Business Unit, Department). Both fields are getting values from Department table (cmn_department).

 

2.  Business Unit is a Reference Field type

Nipan1_0-1716018533297.png

 

3. Department field is a lookup Select box type 

Nipan1_1-1716018638312.png

 

4. Now I want to fetch department based on Business Unit field. And there are 4 Business Units after filtering out via reference qualifier. And each Business Unit having multiple Departments value in the Department table. 

 

I have written a Client Script and a script Include to fetch the values as below :

Client Script:

Nipan1_2-1716019021009.png

 

Script Include:

Nipan1_3-1716019119268.png

 

But it's not working as per the plan, need help to fix my script.

 

Thanks,

Nipan

 

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Hi @Nipan1 ,

 

There is not need for Client Script & Script Include.

 

You can add reference qualifier in lookup select box variable.

Don't forget to add variable attributes.

Reference Qualifier : javascript:'business_unit='+current.variables.YourBusinessUnitVariableName;

Variable attributes: ref_qual_elements=YourBusinessUnitVariableName

 

Sai149_1-1716021430283.png

 

I started answering community questions recently. If my answer helped you in any way, please mark it as helpful or correct. It would be a great boost.

 

View solution in original post

4 REPLIES 4

Community Alums
Not applicable

Hi @Nipan1 ,

 

There is not need for Client Script & Script Include.

 

You can add reference qualifier in lookup select box variable.

Don't forget to add variable attributes.

Reference Qualifier : javascript:'business_unit='+current.variables.YourBusinessUnitVariableName;

Variable attributes: ref_qual_elements=YourBusinessUnitVariableName

 

Sai149_1-1716021430283.png

 

I started answering community questions recently. If my answer helped you in any way, please mark it as helpful or correct. It would be a great boost.

 

Hi @Community Alums,

 

Thanks for your response! The solution you provided works for me.

swathisarang98
Giga Sage

Hi @Nipan1 ,

 

You can write a reference qualifier and script include to return the values as below,

Reference qualifier:

swathisarang98_1-1716022680624.png

 

javascript: new getBusiness().getdp(current.variables.businessUnit);

 

 

 

Script Include:

swathisarang98_0-1716022643327.png

 

var getBusiness = Class.create();
getBusiness.prototype = {
    // initialize: function() {},
    getdp: function(businessUnit) {
		gs.info('5'+ businessUnit);
		var gr = new GlideRecord('cmn_department');
		gr.addQuery('business_unit',businessUnit);
		var arr =[];
		gr.query();
		while(gr.next()){
			arr.push(gr.getValue('sys_id'));
		}
		gs.info('arr' + arr.toString());
		return 'sys_idIN' + arr;

    },
    type: 'getBusiness'
};

 

 

Please mark this comment as Correct Answer/Helpful if it helped you.

Regards,

Swathi Sarang

Hi @swathisarang98 ,

Thanks for your response! I appreciate your input.