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

Notifications

Announcements

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
    302,639 Super User 2026 Season 1 on at

    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

    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

    Thank you very much Andre and Blue Wang.

    It worked well and I got the required output.

    Thanks

    Mohan

  • Martin Dráb Profile Picture
    238,576 Most Valuable Professional on at

    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…

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 695 Super User 2026 Season 1

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 360 Super User 2026 Season 1

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 288 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans