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

Passing date to querydef

Avatar

Avatar
Validate 1
Level 1
MeMonty
Level 1

Likes

4 likes

Total Posts

9 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
Applaud 5
View profile

Avatar
Validate 1
Level 1
MeMonty
Level 1

Likes

4 likes

Total Posts

9 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 3
Boost 1
Applaud 5
View profile
MeMonty
Level 1

28-03-2017

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;

}

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 1
Employee
Vapsy
Employee

Likes

369 likes

Total Posts

726 posts

Correct Reply

342 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 250
View profile

Avatar
Validate 1
Employee
Vapsy
Employee

Likes

369 likes

Total Posts

726 posts

Correct Reply

342 solutions
Top badges earned
Validate 1
Boost 50
Boost 5
Boost 3
Boost 250
View profile
Vapsy
Employee

29-03-2017

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

Answers (0)