- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2023 02:58 AM - edited 04-29-2023 03:05 AM
Dear Experts,
I have total 3 variables,
Variable #1- Name: company; Type: Multiple Choice(None included), Choices (Value): ABC Org, PQR Org, XYZ Org (Order 100, 200, 300 respectively)
Variable #2- Name: job_type; Type: Select Box(None Included), Choices (Value): Dependent, InDependent, Misc (Order 100, 200, 300 respectively)
Variable#3- Name: location_name; Type: Lookup Select Box(None Included; Lookup from table: cmn_location; Lookup value field: Name; No reference qualifier set and No value attributes set).
Requirement is:
If company-ABC Org and job_type-'InDependent' is selected, then display only those 'location_name' (Name) which having Country-'Canada' and 'USA'
If company-XYZ Org and job_type-'InDependent' is selected, then display only those 'location_name' (Name) which having Country-'Italy'
If any/either of 3 provided comapny (ABC Org or PQR Org or XYZ Org) and job_type-'Dependent' is selected, then display only those 'location_name' (Name) which having Country-'Australia'
If any/either of 3 provided comapny (ABC Org or PQR Org or XYZ Org) and job_type-'Misc' is selected, then display only those 'location_name' (Name) which having Country-'Australia', 'Brasil' & 'Japan'
Requesting help on how it can be achieved as I referenced some links just to initiate atleast but unable to get this done. Kindly advise the steps on how this can be achieved .
Thank you in advance. Will mark your response helpful and accepted solution if response helped me on learning.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2023 04:50 AM
@rishabh31 , please try to do it via script include
Adv Ref Qual:
javascript: new AdvRefQuery().getQuery(current.variables.company,current.variables.job_type);
Script Include:
var AdvRefQuery = Class.create();
AdvRefQuery.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getQuery: function(company, jobType) {
if (company == 'ABC Org' && jobType == 'InDependent') {
return 'country=Canada^ORcountry=USA';
} else if (company == 'XYZ Org' && jobType == 'InDependent') {
return 'country=Italy';
} else if ((company == 'XYZ Org' || company == 'PQR Org' || company == 'ABC Org') && jobType == 'Dependent') {
return 'country=Australia';
} else if ((company == 'XYZ Org' || company == 'PQR Org' || company == 'ABC Org') && jobType == 'Misc') {
return 'country=Australia^ORcountry=Brasil^ORcountry=Japan';
}
},
type: 'AdvRefQuery'
});
Hope this helps!
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2023 06:46 AM - edited 04-29-2023 12:00 PM
@rishabh31 , in the variable attributes add this line, it'll work
ref_qual_elements=company;job_type
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2023 04:50 AM
@rishabh31 , please try to do it via script include
Adv Ref Qual:
javascript: new AdvRefQuery().getQuery(current.variables.company,current.variables.job_type);
Script Include:
var AdvRefQuery = Class.create();
AdvRefQuery.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getQuery: function(company, jobType) {
if (company == 'ABC Org' && jobType == 'InDependent') {
return 'country=Canada^ORcountry=USA';
} else if (company == 'XYZ Org' && jobType == 'InDependent') {
return 'country=Italy';
} else if ((company == 'XYZ Org' || company == 'PQR Org' || company == 'ABC Org') && jobType == 'Dependent') {
return 'country=Australia';
} else if ((company == 'XYZ Org' || company == 'PQR Org' || company == 'ABC Org') && jobType == 'Misc') {
return 'country=Australia^ORcountry=Brasil^ORcountry=Japan';
}
},
type: 'AdvRefQuery'
});
Hope this helps!
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2023 06:04 AM
Hi @Karan Chhabra6 ,
Tried and tested, then again did some modifications to check if there was anything I am missing but not found anything, Now even I am wondering why this is not working 😞.
As advised by you I did exactly the same but again it's not worked.
Below is the Ref Qualifier on variable-location_name (lookup reference from cmn_location)
Script include (same code which you provided pasted here, I checked to make it both Client Callable True/false, but not working)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2023 06:46 AM - edited 04-29-2023 12:00 PM
@rishabh31 , in the variable attributes add this line, it'll work
ref_qual_elements=company;job_type
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-29-2023 08:42 AM
Thank you @Karan Chhabra6 for all the responses. This is working amazingly fine🙂 tested in each condition.
Just made a small change in the provided 'variable attributes'
ref_qual_elements=company;job_type
provided comma replaced by a semicolon (referred from URL: https://www.servicenow.com/community/now-platform-forum/variable-attributes-ref-qual-elements/m-p/11...)
So now this variable (location_name) looks like this per the below screenshot.
Script Include looks like-
Hearty thanks for helping me learn and understand this, Marking your 2 responses as helpful and as accepted solutions.
Just a last thing why we used 'Variable attributes' here, I observe after its addition we get desired results.
Kind Regards
Rishabh