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 :
Finance | Project Operations, Human Resources, ...
Suggested answer

Concatenate two or more fields in computed column in view D365fo

(0) ShareShare
ReportReport
Posted on by 199

Hi All,

I've a scenario where i've to concatenate two or more fields on computed column of view. How would it be possible. Any suggestion ? 

I have the same question (0)
  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: Concatenate two or more fields in computed column in view D365fo

    Hi Zohan,

    You can try SysSomputedColumn::addList. You can check this example from PayrollPayStatementEarningLineInquiryEntity -

    private static str formatCompensationPlanAndOption()
    {
        List planOptionList = new List(Types::String);
    
        planOptionList.addEnd(SysComputedColumn::returnField(tableStr(PayrollPayStatementEarningLineInquiryEntity), dataEntityDataSourceStr(PayrollPayStatementEarningLineInquiryEntity, HcmBenefitPlanComp), fieldStr(HcmBenefitPlan, BenefitPlanID)));
        planOptionList.addEnd(SysComputedColumn::returnLiteral(' '));
        planOptionList.addEnd(SysComputedColumn::returnField(tableStr(PayrollPayStatementEarningLineInquiryEntity), dataEntityDataSourceStr(PayrollPayStatementEarningLineInquiryEntity, HcmBenefitOptionComp), fieldStr(HcmBenefitOption, BenefitOptionID)));
    
        return SysComputedColumn::addList(planOptionList);
    }

  • Zohan_93 Profile Picture
    199 on at
    RE: Concatenate two or more fields in computed column in view D365fo

    the add functionality accepts only two arguments. i've to write my own custom method for this ? i guess

  • Suggested answer
    Martin Dráb Profile Picture
    235,966 Most Valuable Professional on at
    RE: Concatenate two or more fields in computed column in view D365fo

    Do you have any particular reason to implement your own solution for dimensions instead of using the standard one? You can check LedgerJournalLineEntity, for example.

    Anyway, the result seems to be what you asked for. If you want to add a delimiter, you could utilize CONCAT_WS() instead of CONCAT(). But you shouldn't - you should use the standard solution, which also respect the standard separator defined in parameters.

  • Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: Concatenate two or more fields in computed column in view D365fo

    You can try using SysComputedColumn::returnLiteral -

    SysComputedColumn::returnLiteral("-"),
    

  • Zohan_93 Profile Picture
    199 on at
    RE: Concatenate two or more fields in computed column in view D365fo

    Yes I've tried it but when ever i tried to use the keyword hyphen "|", it throws an error on build.

    Anyhow i've tried Concat keyword but this shows me in this format, need to add hyphen after dimension change

    below is my result i'm getting using Concat:

    Branch20Department65MainAccount511301Segment54BusinessUnit02

  • Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: Concatenate two or more fields in computed column in view D365fo

    Hi Zohan,

    Adding string fields is equivalent to concatenating them. Did try writing a method for the computed field this way?

  • Martin Dráb Profile Picture
    235,966 Most Valuable Professional on at
    RE: Concatenate two or more fields in computed column in view D365fo

    What's the difference?

  • Zohan_93 Profile Picture
    199 on at
    RE: Concatenate two or more fields in computed column in view D365fo

    Hi Gunjan, I need to concatenate two string fields. not adding them

  • Blue Wang Profile Picture
    on at
    RE: Concatenate two or more fields in computed column in view D365fo

    Hi Zohan,

    Here is a share:community.dynamics.com/.../how-to-concatenate-two-fields-get-from-view-with-hyphen

    More about SysComputedColumn: docs.microsoft.com/.../gg945162(v=ax.60)

  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: Concatenate two or more fields in computed column in view D365fo

    Hi Zohan 93,

    You can use SysComputedColumn::add. Please check the sample code below -

    public static server str stingConcatenate()
    {
        return SysComputedColumn::add(SysComputedColumn::returnField(tableStr(View1), identifierStr(table_1), fieldStr(table1, Field1)),
                                      SysComputedColumn::returnField(tableStr(View1), identifierStr(table_1), fieldStr(table1, Field2))
                                      );
    }

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

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

#1
Sohaib Cheema Profile Picture

Sohaib Cheema 823 User Group Leader

#2
André Arnaud de Calavon Profile Picture

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

#3
Martin Dráb Profile Picture

Martin Dráb 491 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans