Skip to main content

Notifications

Announcements

No record found.

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

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

    An alternative solution is using regular expressions.

  • Mohan_AX Profile Picture
    Mohan_AX 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

  • Verified answer
    Blue Wang Profile Picture
    Blue Wang 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

  • Verified answer
    André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 292,516 Super User 2025 Season 1 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.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,356 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans