web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Error "Query extended range failure: Right parenthesis expected near pos" when open a from

(0) ShareShare
ReportReport
Posted on by

I  have a customized form in AX 2012 R3 with ranges defined on its  query to filter the data retrieved by the form.

 

 When I open the  form, the below error is faced, how can I resolve this error 

Query extended range failure: Right parenthesis expected near pos 35

 

 

.

 

 

 

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    237,976 Most Valuable Professional on at

    Your filter string is wrong, but I obviously can't tell you where exactly is wrong and how to fix it unless you actually show us the code. All I know is what you can read in the error message ("Right parenthesis expected near pos 35").

  • Community Member Profile Picture
    on at

    I am unable to see the image

  • Manjunath Ingalagi Profile Picture
    185 on at

    Hi Martin,

    I'm facing some similar issue here. Can you please tell me what's wrong in the string?

    QueryBuildDataSource   qbdsVehcMas,qbdsTrip;

    Query  query = new Query();

    qbdsTrip = qbdsVehcMas.addDataSource(tableNum(FMSTripRequestTable));

    qbdsTrip.joinMode(JoinMode::NoExistsJoin);

    qbdsTrip.relations(false);

       qbdsTrip.addLink(fieldnum(FMSVehicleMaster,ItemId),fieldnum(FMSTripRequestTable,VehicleNo));

    qbdsTrip.name("FMSTripRequestTable");

       qbdsTrip.addRange(fieldNum(FMSTripRequestTable,PickupDateTime)).value(strFmt('(((%1.%2 <= %4) && (%1.%2 >= %5 )) || ((%1.%3 <= %4) && (%1.%3 >= %5)))',

    query.dataSourceTable(tableNum(FMSTripRequestTable)).name(),fieldStr(FMSTripRequestTable,PickupDateTime),fieldStr(FMSTripRequestTable,DropDateTime),PickupDateTime.valueStr(),DropDateTime.valueStr()));

       qbdsTrip.addRange(fieldNum(FMSTripRequestTable,TripRequestStatus)).value(queryValue(FMSVehicleAssignStatus::Booked));

    I refered the code from these below links,

    1. msdn.microsoft.com/.../aa893981.aspx

    2. community.dynamics.com/.../expressions-in-query-ranges-40-from-axaptapedia-41

  • Martin Dráb Profile Picture
    237,976 Most Valuable Professional on at

    A highly suspicious thing is your lack of formatting of date values. Please try date2StrXpp(PickupDateTime.dateValue()) instead of PickupDateTime.valueStr() (and the same for DropDateTime).

    By the way, if you demonstrated your problem on standard objects (such as SalesTable), people would be able to copy and run your code, which would make it much easier for everybody willing to help you. So you would have better chance to get an answer. Formatting code with the < / > button helps too.

  • Manjunath Ingalagi Profile Picture
    185 on at

    Yea Martin, thanks for the advice on using date2StrXpp. As I am just a rookie so I don't know if I can form scenario's using the standard tables. Well my scenario is something is like this. I get two utcdatetime fields like To and From, from a dialog form and I've a lookup in the dialog which has to give lookup based on the values from a table which has datetime fields. So my job is to check if the datetime field values that I get from the dialog is falls in the range of the dateTime fields which are there in the table. I hope you got what I am trying to do.

    And back to the main question, why do we get this error? "Query extended range failure: Right parenthesis expected near pos XX" ?? Could you indentify the mistake in my code except for the Date2strXpp thing??

  • Martin Dráb Profile Picture
    237,976 Most Valuable Professional on at

    Does it mean that date2StrXpp() didn't make any difference? In that case, please your update code and I'll convert it to something that doesn't depend on your custom tables.

  • Verified answer
    Manjunath Ingalagi Profile Picture
    185 on at

    Hi Martin,

    I cannot use date2strXpp() as it takes only date as a parameter and my fields are utcdateTime. So I used dateTime2str function. But still I am getting the same error. I think it wont make any difference if we use valueStr() unless it is something that would be not compatible to use in query ranges of this kind. And also can you please tell me what you meant by updating the code in the above post? The code I have put here is the actual code that I have used in the development. If you need some more details to resolve the issue then please let me know.

  • Manjunath Ingalagi Profile Picture
    185 on at

    Hi Martin,

    I found the solution. I just used double quotes for the those parameters in the string filter. This is what I did.

    qbr.value(strFmt('(((%1.%2 <= "%4") && (%1.%2 >= "%5"))||((%1.%3 <= "%4") && (%1.%3 >="%5")))', query.dataSourceTable(tableNum(FMSTripRequestTable)).name(), fieldStr(FMSTripRequestTable,PickupDateTime), fieldStr(FMSTripRequestTable,DropDateTime), PickupDateTime.valueStr(), DropDateTime.valueStr()));

    As you can see I have added double quotes for the 4th and the 5th parameter. Now I am no longer getting the error.

  • ArunGarg Profile Picture
    3,926 on at

    Hi,

    So you got the solution?

    Regards

    Arun

  • Manjunath Ingalagi Profile Picture
    185 on at

    Hi Arun,

    Yea I got the error resolved.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans