Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

Replace character in string through code X++ D365 F&O

(0) ShareShare
ReportReport
Posted on by 752

HI Everyone,

I have one sample string below,

str  formula = "A+0.3*B+AC";

Now I want to replace character A first with some value and then AC with some Value.

I am trying to build formula. Please suggest how can I achieve this?

If I use strReplace my formula gets modified as below

modFormula = strReplace(formula, "A", "15");

modFormula = 15+0.3*B+15C

It not only replaces first A but also A from AC.

Is there any solution?

  • WillWU Profile Picture
    22,357 on at
    RE: Replace character in string through code X++ D365 F&O

    Hi Rhushikesh Raut,

    You could also try

    modFormula = strReplace(formula, "A+", "15+");

  • Suggested answer
    Martin Dráb Profile Picture
    233,675 Most Valuable Professional on at
    RE: Replace character in string through code X++ D365 F&O

    The easiest option is replacing AC string first and only then replacing A.

  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: Replace character in string through code X++ D365 F&O

    Hi Rhushikesh,

    You can try two functions for this -

    1. strFind() to find the first position of A.

    2. strPoke to replace A with the value.

    Please check here for examples.

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 the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

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

#1
Martin Dráb Profile Picture

Martin Dráb 456 Most Valuable Professional

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 310

#3
Saalim Ansari Profile Picture

Saalim Ansari 261

Overall leaderboard

Product updates

Dynamics 365 release plans