queryparam not getting resolved in SQL Javascript

I am using below Javascript. When I debug the ‘FinalWQLSelectQry’ I am expecting the value to be passed in where clause. But when I debug i get where clause as

WPA_LoadTimestamp >=‘lastupdate’

How to pass date value in the SQL query within javascript ?

var headerdata = context.getVariable('request.header.data');
var lastupdate = context.getVariable('request.queryparam.lastupdate');

if (headerdata === 'active')
{
var SQLSelect = 'SELECT ASOFDATE,WPA_LoadTimestamp,EMPLID,FIRST_NAME_PRIOR FROM cds_WD_MMC_ActiveEE_DELTA_TBL WHERE (FIRST_NAME_PRIOR IS NOT NULL OR isLEGAL_PRIOR IS NOT NULL OR isTECH_PRIOR IS NOT NULL OR isCIO_PRIOR IS NOT NULL) and WPA_LoadTimestamp >=' + '\'lastupdate\'';
}

var FinalWQLSelectQry = SQLSelect;
context.setVariable('FinalWQLSelectQry', FinalWQLSelectQry);

{
“error”: “invalid request: WQL error.”,
“errors”: [
{
“error”: “There was an issue resolving the WQL query.”,
“location”: “Invalid WHERE clause”
}
]
}

But when I debug i get where clause as WPA_LoadTimestamp >=‘lastupdate’ How to pass date value in the SQL query within javascript ?

From your JS, that’s what I would expect. You have a Javascript line like this:

var SQLSelect = 'SELECT ...  WHERE (...) and WPA_LoadTimestamp >=' + '\'lastupdate\'';

and that will resolve to

SELECT ...  WHERE (...) and WPA_LoadTimestamp >='lastupdate'

Can you give an example of what you are aiming for? What do you want the WQL to look like? (Assume I don’t know anything about WQL)

It is working now with below code

var lastupdate = context.getVariable('request.queryparam.lastupdate');
var lsd = "'" + lastupdate + "'";

and WPA_LoadTimestamp >= '+ lsd;
1 Like