Grid main query do not feels a global variable

Hello all,
I got a grid that request as global variable ‘[glo_SalesdirID]’ set to " IN ".
When I run the application it ask me for it and I give it.
If I do a echo of it OnApplicationInit it gives me the right value.

I inserted it within main query just to filter data to a single manager --> SalesdirID
When I use the debug to understand the problem I find that select has not taken the value for that variable and the join is like

[SIZE=12px]LEFT JOIN customers ON customers.SalesdirID = ‘’ AND orders.CustomerID = customers.CustomerID ) [/SIZE]

Sorry… I’m not able to understand why. Is the query not correctly written ??
Please give in a hint… :wink:

SELECT
OrderID,
StatusID,
orders.CustomerID AS CustomerID01 ,
(SELECT customers.CompanyName FROM customers WHERE CustomerID = orders.CustomerID) AS RagSoc,
orders.SalesmanID AS SalesmanID01,
EmployeeID,
Note_Header,
OrderDate,
RequiredDate,
Expenses,
Id_Ord, Tipo_Ord, Nr_Ord,
(SELECT SaleseosID FROM customers WHERE CustomerID = orders.SalesmanID) AS SaleseosID,
(SELECT SalesdirID FROM customers WHERE CustomerID = SalesmanID01) AS SalesdirID
FROM
orders
LEFT JOIN customers ON customers.SalesdirID = ‘[glo_SalesdirID]’ AND orders.CustomerID = customers.CustomerID
ORDER BY RagSoc ASC ,
OrderID DESC