Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / Replace character in s...
Finance forum
Suggested answer

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

Posted on by 742

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
    WillWU 22,344 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
    Martin Dráb 225,672 Super User 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
    Gunjan Bhattachayya 35,417 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.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 288,420 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,672 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans