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

Announcements

No record found.

News and Announcements icon
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?

  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    35,429 on at

    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.

  • Suggested answer
    Martin Dráb Profile Picture
    240,748 Most Valuable Professional on at

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

  • WillWU Profile Picture
    22,363 on at

    Hi Rhushikesh Raut,

    You could also try

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

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

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

#1
Martin Dráb Profile Picture

Martin Dráb 426 Most Valuable Professional

#2
CU10121822-0 Profile Picture

CU10121822-0 358

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 353 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans