Charan
09/21/2022, 8:24 PM`SELECT
Transaction.ID,
Transaction.trandate as InvoiceDate,
Transaction.tranid,
Transaction.foreigntotal as total,
BUILTIN.DF(Transaction.entity) as Customer
FROM
Transaction
WHERE
( (Transaction.Type = 'CustInvc' ) OR (Transaction.Type = 'CashSale') )
CASE WHEN 2 > 1 THEN
Transaction.ID = 93732
END;
AND
Transaction.approvalstatus = 1
ORDER BY
Transaction.Trandate ASC,
Transaction.ID ASC`;
Taylor
09/21/2022, 9:03 PMTransaction.ID = CASE...END
and the case statement returns an ID based on conditions. Also, there are two semicolons in that example, don't think you want that. I've never built a case statement that conditionally appends part of the where clause, not sure that's possible -- I have done that in a scripting language to dynamically build the query string, however. But, more context on what type of condition you're wanting to use. It's also nice to get to a point of success -- so if you removed from the start of the case statement through the end, the new query should work, then add one condition at a time to ensure you still have a valid query.Charan
09/21/2022, 9:12 PMCharan
09/21/2022, 9:13 PMWHERE
if(value){
Transaction.ID = 93732
}
Charan
09/21/2022, 9:14 PMTaylor
09/21/2022, 9:15 PMCharan
09/21/2022, 9:15 PMTaylor
09/21/2022, 9:16 PMCharan
09/21/2022, 9:16 PMTaylor
09/21/2022, 9:17 PMTransaction.ID = 1234
I think it has to return a value, and that value can be used in an expression.Charan
09/21/2022, 9:24 PMTaylor
09/21/2022, 9:27 PMvar query = select ...;
then in the js if(value) { query += ' and Transaction.ID = ' + value; }
- something along those lines.Taylor
09/21/2022, 9:28 PM;
in the initial query or that'll cause an issue if you do append the other condition ha. But you get the idea.