Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

Passing date to querydef

MeMonty
Level 2
Level 2

Hi,

I have written a function (as shown below) to fetch all the deliveries on a day. For the same I am passing two dates today & tomorrow (with time part of 00:00:00). But I am getting an error

Error while executing the method 'ExecuteQuery' of service 'xtk:queryDef'.

Unable to parse expression '@created >= Tue Mar 28 2017 09:42:30 GMT+0000 (UTC)'.

Element 'Tue' unknown (see definition of schema 'Deliveries (nms:delivery)').

//  ==========   function getDeliveries()   ==========

function getDeliveries(paramDate1, paramDate2)

{

  var deliveriesArray = new Array();

  logInfo("BEGIN (function) ... getDeliveries()");

  logInfo("Type of Parameter-1 ... : " + typeof paramDate1 + "      Type of Parameter-2 ... : " + typeof paramDate2);

  logInfo("Parameter-1 ... : " + paramDate1.toString() + "      Parameter-2 ... : " + paramDate2.toString());

  var query = xtk.queryDef.create(

    <queryDef schema="nms:delivery" operation="select">

      <select>

        <node expr="@id"/>

      </select>

      <where>

        <condition expr={"@created >= " + Date(paramDate1)}/>

        <condition booleanOperator="AND" expr={"@created < " + Date(paramDate2)}/>

      </where>

    </queryDef>);

    var res = query.ExecuteQuery();

    var i = 0;

    for each (var delivery in res.delivery)

    {

      deliveriesArray.push(delivery.@id);

      i++;

    }

  var arrLen = deliveriesArray.length;

  logInfo("Number of Deliveries ... : " + arrLen);

  logInfo("END (function) ... getDeliveries()");

  return deliveriesArray;

}

1 Accepted Solution
Vapsy
Correct answer by
Employee
Employee

Hi Mahantesh,

QueryDef takes data parameters in this format

expr="@created &gt;= #2017-03-26 22:00:00.000Z#"

So the params you are passing has to be in this format.

Regards,

Vipul

View solution in original post

1 Reply
Vapsy
Correct answer by
Employee
Employee

Hi Mahantesh,

QueryDef takes data parameters in this format

expr="@created &gt;= #2017-03-26 22:00:00.000Z#"

So the params you are passing has to be in this format.

Regards,

Vipul

View solution in original post