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 :
Microsoft Dynamics AX (Archived)

How to get Space between ComputedColumn

(0) ShareShare
ReportReport
Posted on by

Hai all,

I have  Two Fields  Name ,Surname i want to combined both fields as single field and sapce.

i did like that .

public static server str add()
{

return

" select top 1 cast(fname as varchar(15)) + ' ' + cast(lname as varchar(15)) as fullname";

}

 

suggest another  way.. 

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Community Member Profile Picture
    on at

    Hi,

          You can see this code, and the below code is suggest by Microsoft in MSDN.

           computed column is not specially mean for spacing.  Please look into the below code, you will come to know on spacing.

    private static server str compColSubsegAcctMethod()
    {
        #define.ViewName(TestCompColView)
        #define.DataSourceName("CustTable_1")
        #define.FieldSubsegmentId("SubsegmentId")
        #define.FieldAccountNum("AccountNum")
        str sReturn,
            sAccountNum,
            sSubsegmentId;
        DictView dictView2;
    
        // Construct a DictView object for the present view.
        dictView2 = new DictView(tableNum(#ViewName));
    
        // Get a string that has the target field name
        // propertly qualified with an alias (such
        // as "A." or "B.").
        sAccountNum = dictView2.computedColumnString
            (#DataSourceName,
            #FieldAccountNum,
            FieldNameGenerationMode::FieldList,
            true);
    
        sSubsegmentId = dictView2.computedColumnString
            (#DataSourceName,
            #FieldSubsegmentId,
            FieldNameGenerationMode::FieldList,
            true);
    
        sReturn = "substring("
            + sSubsegmentId
            + ",1,1) + ' - ' + "
            + sAccountNum;
    
        // Helpful confirming or diagnostic information.
        info(sAccountNum);
        info(sSubsegmentId);
        info(sReturn);
    
        return sReturn;
    }

    Thanks

    Suresh

  • Suggested answer
    Pravasti AK Profile Picture
    2,985 on at

    Hi,

    Display str add()

    {

       str output;

    ;

       output = strfmt("%1 %2", this.fname,this.lname);

     return output

    }

  • Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    since that's SQL syntax that will be transformed to view so you can also use SPACE function of SQL Server

    +SPACE(5)+

    --You can reduce or increase 5 , depending upon as many chars as you may want.

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans