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 :
Small and medium business | Business Central, N...
Suggested answer

How to Extract [split] Key-Value Pair from the Text Field using AL code?

(0) ShareShare
ReportReport
Posted on by 2,100

Hi All,

I have one custom Text Field in the Bank Acc. Reconciliation Line table in the Business Central. In that field, I have the below value.

Value is:

FROM:CO NAME=Test, Test ,Test;CO.ID#=0123456789;ENTRY DESC=Test;INDIV NAME=Test2;INDIV.ID#=000000000000000; PAR=0000000000000; ACH LOCATION #0000000000;

So Challenge is:

I need to extract this field because I want a separate each key-value pair after semicolon from this field and store that value and use that.

For example like this,

CO NAME [key]=Test, Test, Test [value];

CO.ID# [key]=0123456789 [value];

ENTRY DESC [key]=Test [value];

INDIV NAME [key]=Test2 [value];

INDIV.ID# [key] =000000000000000 [value];

PAR [key]=0000000000000 [value];

Is there any way to do it In the AL code?

Any help will be appreciated.

Thank you.

I have the same question (0)
  • Suggested answer
    Nitin Verma Profile Picture
    21,698 Moderator on at
    RE: How to Extract [split] Key-Value Pair from the Text Field using AL code?

    Hi,

    I can't find the this field " Key-Value pair" in your text string.

    Which field you want to extract?

    Thanks.

  • Inkey Solutions Profile Picture
    2,100 on at
    RE: How to Extract [split] Key-Value Pair from the Text Field using AL code?

    FROM:CO NAME=Test, Test ,Test;CO.ID#=0123456789;ENTRY DESC=Test;INDIV NAME=Test2;INDIV.ID#=000000000000000; PAR=0000000000000; ACH LOCATION #0000000000;

    I want to extract Test, Test ,Test from CO NAME, likewise

    0123456789 from CO.ID# and here CO Name is My key and Test, Test, Test is my Value.

  • Suggested answer
    Nitin Verma Profile Picture
    21,698 Moderator on at
    RE: How to Extract [split] Key-Value Pair from the Text Field using AL code?

    Hi,

    You can use as per below

    Saveithere := SelectStr(1,yourstring);

    Saveithere := SelectStr(2,yourstring);

    Saveithere := SelectStr(3,yourstring);

    Saveithere := SelectStr(4,yourstring);

    Saveithere := SelectStr(5,yourstring);

    Thanks

  • Inkey Solutions Profile Picture
    2,100 on at
    RE: How to Extract [split] Key-Value Pair from the Text Field using AL code?

    Hi,

    Thanks for the prompt reply,

    But I am facing one issue with this solution. Actually, I have one or more row of that field and my string value contains semicolon So how can I use this function dynamically?

    You can see the below screen print for My Text Field value.

    pastedimage1665830416013v1.png

    >> I tried something below code, but it didn't work as expected.

    pastedimage1665830544243v2.png

    Thank you.

  • Suggested answer
    Amit Profile Picture
    2,557 on at
    RE: How to Extract [split] Key-Value Pair from the Text Field using AL code?

    Hi,

    Refer the below for doing the above activity

    https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/text/text-copystr-method

    Regards

    Amit Sharma

    www.erpconsultors.com

  • Suggested answer
    YUN ZHU Profile Picture
    95,083 Super User 2025 Season 2 on at
    RE: How to Extract [split] Key-Value Pair from the Text Field using AL code?

    Hi, Have you tried List Data Type and Text.Split(List of [Text]) Method?

    https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/list/list-data-type

    Text.Split(List of [Text]) Method

    https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/text/text-split-list%5Btext%5D-method

    Here is a simple example:

    https://yzhums.com/15962/

    Hope this helps.

    Thanks.

    ZHU

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,686

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 3,529 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,989 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans