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)

X++ Query removing preceeding whitespace from range

(0) ShareShare
ReportReport
Posted on by

Hi All,

We have a query in AX2012 R2 that needs to filter by a packing slip ID in such a way:

qbdsInventTrans.addRange(fieldNum(InventTrans, PackingSlipId)).value(' 466/Z');

The important part to note is the initial whitespace before 466/Z which should match the value in the database. As soon as the range gets added to the query the whitespace is being removed (I can see its removed from the Query object text while debugging) so the range does not match what is in the database.

How do I configure the query or range so that it does NOT remove the whitespace?

Thanks!

Dale

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Denis Macchinetti Profile Picture
    16,444 on at

    Hi Dale

    Try something like :

    qbdsInventTrans.addRange(fieldNum(InventTrans, PackingSlipId)).value("\" 466/Z\"");

    Regards

  • Dale Thornton Profile Picture
    on at

    Thanks Denis!! That worked perfectly you're a life saver.

  • Verified answer
    Douglas Noel Profile Picture
    3,905 on at

    Hi Dale,

    you should use one of the following methods or built-in functions, if you want to assign a single value to an range

       .....value ( queryValue(yourvalue) );

       .....value ( SysQuery::value(yourvalue));

    they do the complete escaping for you - never assign strings as query value directly, beside you are absolutely sure that they don't need to be escaped

    the comma for example has to be escapred, the backslash the leeading blanks and so on...

    regards

    Douglas

  • Suggested answer
    Community Member Profile Picture
    on at

    in this case you should use StrLtrim() and StrRtrim()

    one method we should use always use is QueryValue()

    please verify.

  • Suggested answer
    Dale Thornton Profile Picture
    on at

    Ah that makes more sense, will be using this solution for sure. Thanks Douglas :)

  • Denis Macchinetti Profile Picture
    16,444 on at

    Hi Guys

    I'm agree with Douglas.

    I gave a quick response.

    I'm agree in using QueryValue(..) method.

    Thanks

    Regards

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