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.
  • Karuna Dogra Profile Picture
    on at
    Converting array to str and storing in a field
    That worked. Thanks a lot Martin (The Genius). This thread can be closed. 
     
    regards
    Karuna
  • Verified answer
    Martin Dráb Profile Picture
    233,013 Most Valuable Professional on at
    Converting array to str and storing in a field
    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
    Converting array to str and storing in a field
    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
  • Martin Dráb Profile Picture
    233,013 Most Valuable Professional on at
    Converting array to str and storing in a field
    FilterCode is an array field, not a container.
  • Suggested answer
    Bharani Preetham Peraka Profile Picture
    3,624 Moderator on at
    Converting array to str and storing in a field
    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. 
  • Verified answer
    Martin Dráb Profile Picture
    233,013 Most Valuable Professional on at
    Converting array to str and storing in a field
    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];
    }
    

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,261 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 233,013 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans