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

Converting array to str and storing in a field

(1) ShareShare
ReportReport
Posted on by
////Hi Team,
 
I have created a custom entity for whsinventtable and created a virtual field called strfilterCode. In postload method, I want to store filtercode array field value to this virtual field. How can I convert array to str and store in this virtual field? Please help.
I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,987 Most Valuable Professional on at
    Do you want values separated by a delimiter?
     
    You could use something like this:
    for (int i = 1; i <= dimOf(whsInventTable.FilterCode); i++)
    {
        if (this.StrFilterCode)
        {
            this.StrFilterCode += ',';
        }
    
        this.StrFilterCode += whsInventTable.FilterCode[i];
    }
    
  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    3,634 Moderator on at
    Are you saying you have a container value to be stored in a string field? If yes, then you can make use of standard con2str() and pass any delimiters if you need. 
  • Martin Dráb Profile Picture
    237,987 Most Valuable Professional on at
    FilterCode is an array field, not a container.
  • Karuna Dogra Profile Picture
    on at
    Thank you so much Martin, that works. Also, I have been trying to mark that check box does this question your answer but its just keep buffering.
     
    Can you please also guide, how I can avoid extra comma in the string field StrFilterCode in case out of 5 indexes (Filter code 1, Filter code 2, Filter code 3....) only one index has value? It is storing the value like this  Item1,,,,
     
    Please guide.
     
    Thank you
  • Verified answer
    Martin Dráb Profile Picture
    237,987 Most Valuable Professional on at
    It's trivial - you just need a condition to skip adding the separator if the filter code value is empty. For instance:
    for (int i = 1; i <= dimOf(whsInventTable.FilterCode); i++)
    {
        str filterCode = whsInventTable.FilterCode[i];
    
        if (filterCode && this.StrFilterCode)
        {
            this.StrFilterCode += ',';
        }
    
        this.StrFilterCode += filterCode;
    }
  • Karuna Dogra Profile Picture
    on at
    That worked. Thanks a lot Martin (The Genius). This thread can be closed. 
     
    regards
    Karuna

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
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 420 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 241 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans