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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

String modification operations in X++

(0) ShareShare
ReportReport
Posted on by 85

Hi Experts,

 

I have a table column with datatype EdtString with String Size Memo and few number of records with different values.

Tried with strReplace() & StrKeep() but didn't worked out since the value of properties will be different for different records.

Example for a particular row of record.

 

String Stored in Table :

{"Source":"D365A","JobTypeId":"Clerical","Description":"Clerical","ExemptStatus":"NonExempt","PaidHourly":"No","ExtIntId":16928090031}

 

Is there a way to remove the below highlighted property and values (values may be different for different rows in table) for Source & ExtIntId and display it in UI.

{"Source":"D365A","JobTypeId":"Clerical","Description":"Clerical","ExemptStatus":"NonExempt","PaidHourly":"No","ExtIntId":16928090031}

 

So, the expected result string looks like

{"JobTypeId":"Clerical","Description":"Clerical","ExemptStatus":"NonExempt","PaidHourly":"No"}

 

Thanks Much

Anoop

I have the same question (0)
  • Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    You have two main options: Either you'll work with it just as with a generic text, or you'll utilize the fact that it's JSON (e.g. you deserialize JSON to an object and work with the object).

    I think the best solution may be using System.Text.RegularExpressions.Regex::Replace().

    Let us know if you need help with writing the regular expressions.

  • AnoopNair Profile Picture
    85 on at

    Thanks much for the input Martin!

    Yes i was thinking of deserialize JSON as an object as one of the solution option.

    Can you please help me to understand more on writing the regular expressions as that may be one of the best solution approach for this scenario to proceed on.

  • Verified answer
    Martin Dráb Profile Picture
    237,965 Most Valuable Professional on at

    Try the following pattern:

    "Source":"[^"]*",|,"ExtIntId":\d 

    To test it, you can use an online Regex tester (which is what I did). Tick "Replace matches with.." checkbox and leave the replacement value empty, which will replace texts matching the pattern with an empty string.

    If you're not familiar with regular expressions, it'll help you if I explain the pattern a little bit...

    The pattern consists of two sub-patterns; one for Source and one for ExtIntId. It'll find texts matching either of these two patterns.

    The first pattern is

    "Source":"[^"]*",

    It finds texts starting with "Source":" (nothing complicated here), followed by any number of characters (including zero) except of ". If we included ", we would match more than what we wanted. And then the string must continue with ", (we want to match the comma as well, so it gets removed when we replaced the matching string with an empty string).

    The other pattern is even simpler:

    ,"ExtIntId":\d 

    \d matches one or more digits.

  • AnoopNair Profile Picture
    85 on at

    Thanks Much Martin!

    Details provided helps lot for me to understand more on Regex and proceed with the solution

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 451 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans