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

Announcements

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

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,812 Moderator on at

    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,122 on at

    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,812 Moderator on at

    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,122 on at

    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,563 on at

    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
    101,995 Super User 2026 Season 1 on at

    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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,314 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,781 Super User 2026 Season 1

#3
AndrewThomas81 Profile Picture

AndrewThomas81 1,356

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans