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)

String concatination

(0) ShareShare
ReportReport
Posted on by

hi all,

in table i have two fields: fname ,lname.

form data source as table but i want to display "name " in form , how to concatenate two fields (fname,lname)  using display method.

 thanks&regards

j.lalitha

*This post is locked for comments

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

    In Display method you can write like this

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

  • Verified answer
    Community Member Profile Picture
    on at

    Hi,

          Take a look here,

    2Fields.JPG

    Try this this code :

    Display str FullNam()
    {
        
        TestFieldLocking testFieldLocking;
        
        select * from testFieldLocking
            where testFieldLocking.CustAcc == this.CustAcc;
        
        return(testFieldLocking.FirstName + " " + testFieldLocking.LastName);
    }


    I think this is your solution, Please mark if it helps you!

    Thanks

    Suresh

  • Martin Dráb Profile Picture
    237,978 Most Valuable Professional on at

    The first suggestion is better, because:

    1. It doesn't make a query to database for each value to display. Putting select statements to display methods is the main reason why they're so often a performance killer.
    2. Support for localization (e.g. different sequence of names) can be achieved simply by replacing "%1 %2" with a label, which can then be defined differently in different languages.
  • Verified answer
    Community Member Profile Picture
    on at

    Hi,

        I respect Martin Suggestion, As he said please follow some best practices for display method like,

       

    select FisrtName, LastName from testFieldLocking
        where testFieldLocking.CustAcc == testFieldLocking.CustAcc;
    return(testFieldLocking.FirstName + " " + testFieldLocking.LastName);

    And Also please find below links,

        https://msdn.microsoft.com/en-us/library/aa602944.aspx

        https://msdn.microsoft.com/en-us/library/aa641216.aspx

        Example scenario :

    Bad solution:

    Private
    boolean
    validateSalesOrder(SalesId _salesId)
    {
    SalesTable              salesTable;
    SalesLine               salesLine;
    SalesLineType_Sales     salesLineType;
    boolean
    ret = 
    true
    ;
    while
    select
    salesTable 
    where
    salesTable.SalesId == _salesId
    76
    BEST PRACTICES FOR D
    EVELOPING CUSTOMIZAT
    IONS
    join
    salesLine 
    where
    salesLine.SalesId == salesTable.SalesId
    {
    if
    (salesTable.CashDiscPercent < 
    0
    )
    {
    ret = ret && checkFailed(
    "<Error message>"
    );
    }
    if
    (salesTable.SalesDiscAmount < 
    0
    )
    {
    ret = ret && checkFailed(
    "<Error message>"
    );
    }
    if
    (!salesTable.DeliveryDate)
    {
    ret = ret && checkFailed(
    "<Error message>"
    );
    }
    salesLineType = SalesLineType_Sales::construct(salesLine);
    //
    //salesLineType...
    //..
    //
    }
    return
    ret;
    }

    Good solution:

    Private
    boolean
    validateSalesOrder(SalesId _salesId)
    {
    SalesTable              salesTable;
    SalesLine               salesLine;
    SalesLineType_Sales     salesLineType;
    boolean
    ret = 
    true
    ;
    while
    select
    CashDiscPercent, SalesDiscAmount, DeliveryDate, SalesId 
    from
    salesTable
    where
    salesTable.SalesId == _salesId
    join
    salesLine 
    where
    salesLine.SalesId == salesTable.SalesId
    {
    if
    (salesTable.CashDiscPercent < 
    0
    )
    {
    ret = ret && checkFailed(
    "<Error message>"
    );
    }
    if
    (salesTable.SalesDiscAmount < 
    0
    )
    {
    ret = ret && checkFailed(
    "<Error message>"
    );
    }
    if
    (!salesTable.DeliveryDate)
    {
    ret = ret && checkFailed(
    "<Error message>"
    );
    }
    77
    BEST PRACTICES FOR D
    EVELOPING CUSTOMIZAT
    IONS
    salesLineType =
    SalesLineType_Sales::construct(salesLine);
    //
    //salesLineType...
    //..
    //
    }
    return
    ret;
    }

    Thanks

    Suresh

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