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

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Reading specific text from a string using X++ functions

(0) ShareShare
ReportReport
Posted on by 106

Dear AX Experts,

Can someone please share an idea on how  to read specific text from a string ? example as below

Example String = "thisisPIV567898invoicenumber"

Required output text  = PIV567898

Note: The position of text can be changed, irrespective of the position, I need to read first instance of text starting with "PIV" followed by 6 digits

More examples of string as below

"PIV984567secondinvoiceexample"

"/inv/PIV056342/zvest"

"Z&X MAN FOREST INVPIV052514, PIV060148 PIV062270 "  ( in this scenario output should be PIV052514).

Please help, thanks in Advance

I have the same question (0)
  • Verified answer
    André Arnaud de Calavon Profile Picture
    300,721 Super User 2025 Season 2 on at
    RE: Reading specific text from a string using X++ functions

    Hi Mohan,

    Using the strScan() function, you can determine the position of the text PIV. Then you can use the subStr() command to read from the start of PIV until the end of the 6 numbers.

  • Verified answer
    Blue Wang Profile Picture
    on at
    RE: Reading specific text from a string using X++ functions

    Hi Mohan,

    Please use the method suggested by Andre, the simple example is as follows:

    2514.PNG

    https://docs.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/dev-ref/xpp-string-run-time-functions#strscan

  • Mohan_AX Profile Picture
    106 on at
    RE: Reading specific text from a string using X++ functions

    Thank you very much Andre and Blue Wang.

    It worked well and I got the required output.

    Thanks

    Mohan

  • Martin Dráb Profile Picture
    237,679 Most Valuable Professional on at
    RE: Reading specific text from a string using X++ functions

    An alternative solution is using regular expressions.

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 683 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 563 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 398 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans