Hi Experts / Kristian Ekenes,
Unfortunately I don't have a working example to share as the data that I am working on is client sensitive.
I am using a Unique Value Renderer to colour various types of pipelines with the PRODUCT feature/attribute and it works fine without a value expression.
In my JS code, I have a variable, say routeName which has a name say "ABC". Now what I need is the value expression to consider the local variable which is not happening 
I also tried with field and field1 and filedDelimiter as ",', but even this is not working. Need help on how to access this.
The whole idea is if I select a particular route on the map, I need to change the opacity of the other routes in this layer, so if I can get this to work, then I can add the opacity.
var routeName = "ABC";
var pipelineRenderer = {renderer: {
type: "unique-value",
field: "PRODUCT",
valueExpression: "When($feature.PRODUCT = "OIL" && $feature.ROUTE_NAME != routeName, 'OIL', $feature.PRODUCT = "GAS" && $feature.ROUTE_NAME != routeName, 'GAS', 'OTHERS')",
defaultSymbol: {
type: "simple-line",
color: "black",
width: 2
},
uniqueValueInfos: [
{
value: 'OIL',
symbol: {
type: "simple-line",
color: "red",
width: 3
}
},
{
value: 'GAS',
symbol: {
type: "simple-line",
color: "yellow",
width: 2.5
}
}
]
}}
pipeLineLayer.set(pipelineRenderer);
pipeLineLayer.refresh();
I even tried to do below but its throwing Syntax Error - if I can access the DOM and take the value which I can use in my When expression, that should also work:
valueExpression: `
var selectFilter = document.getElementsByTagName("select");
var opts = selectFilter[0].options;
var route = selectFilter.item(0).item(selectFilter.item(0).selectedIndex).value.split("|")[0].split(":")[1].trim();
Console("Selected Route: " + route);
When($feature.PRODUCT == 'GAS', 'GAS', $feature.PRODUCT == 'OIL', 'OIL', 'OTHERS')`,