Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Unable to see AmoutCur field of CustTrans in a computerColumn of a View.

Posted on by Microsoft Employee

Hi,

I want AmountCur field of CustTrans to be displayed from a computed column of the view. But I'm facing an error as below.

SQL error description: [Microsoft][SQL Server Native Client 10.0][SQL Server]Arithmetic overflow error converting expression to data type nvarchar.

Following is the code

public server static str amount()
{
    return SysComputedColumn::returnField(tableStr(ViewTest),identifierStr(CustTrans_1),fieldStr(CustTrans,AmountCur));
}

Other fields like AccountNum, Approved are working fine though. I think its accepting other data types except real.

Can some one please help.

Thanks,

Praveen

*This post is locked for comments

  • Martin Dráb Profile Picture
    Martin Dráb 230,198 Most Valuable Professional on at
    RE: Unable to see AmoutCur field of CustTrans in a computerColumn of a View.

    When do you get the error? If synchronization succeeded and you get this error at runtime, look at T-SQL definition of the view (through SQL Server Management Studio).

    Also, what's the type of your computed column?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Unable to see AmoutCur field of CustTrans in a computerColumn of a View.

    I found a fix for this. I used convert() function of SQL and I was able to get the out put.

    public server static str amount()

    {
        str rr;
        rr = strFmt("CONVERT(float, %1)",
                SysComputedColumn::returnField( 
                    tableStr(ViewTest),
                        identifierStr(CustTrans_1),
                            fieldStr(CustTrans,AmountCur)));
        return rr;
    }

    I'm still not clear as why it did not work when I used  

    rr = SysComputedColumn::returnField( 
                    tableStr(ViewTest),
                        identifierStr(CustTrans_1),
                            fieldStr(CustTrans,AmountCur)
    
    or 
    
    rr = strFmt("%1",
                SysComputedColumn::returnField( 
                    tableStr(ViewTest),
                        identifierStr(CustTrans_1),
                            fieldStr(CustTrans,AmountCur)));

    as they both returns a string any way and the variable can accept it.

    How come it gave an error in the beginning but its working when I used the CONVERT() of SQL I'm not sure.

    Thanks,

    Praveen

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans