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, ...
Suggested answer

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

(0) ShareShare
ReportReport
Posted on by 758

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?

I have the same question (0)
  • WillWU Profile Picture
    22,361 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
    236,275 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,239

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 604 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans