0

I have a View in AX with a computed column:

    private static server str qty()
    {
    #define.THEN(" THEN ")
    #define.SINGLE_QUOTE("'")

    return 'CASE T2.ReturnStatus ' +
                ' WHEN  ' + int2str(enum2int(ReturnStatusLine::None))   + #THEN + '-1 * T3.UnitValue' +
                ' WHEN  ' + int2str(enum2int(ReturnStatusLine::Awaiting))   + #THEN + '-1 * T3.UnitValue' +
                ' WHEN  ' + int2str(enum2int(ReturnStatusLine::Registered))   + #THEN + '-1 * T3.UnitValue' +
                ' ELSE  ' + "(T3.UnitValue / T2.ExpectedRetQty * (SELECT TOP 1 SUM(cpst.Qty) as RcvQty from custPackingSlipTrans as cpst where cpst.InventTransId = T2.InventTransId and cpst.dataAreaId='" + curext() + "')) * -1" +
                ' END'; 
   }

It works great, except the past week or so the column is returning NULL when it should not be. This is fixed simply by going into the AOT and syncing this view, after that the column has a valid value. But we're having to do this almost daily.

Any ideas?

joel
  • 156
  • 6
  • 2
    AX2012R3 I'm assuming? Are you on an updated kernel? Multiple AOS's? Are all their kernel's in sync? My initial guess is you need to update your kernel and/or initialize your AX modelstore if you haven't already https://learn.microsoft.com/en-us/dynamicsax-2012/appuser-itpro/initialize-axmodelstore . This is just a guess because you're saying the issue is fixed via sync's. – Alex Kwitny Jan 28 '20 at 15:49
  • 5
    Also you will have the curext() value baked in, so it will only work in the company where it is synchronised! See the view from SQL. – Jan B. Kjeldsen Jan 28 '20 at 15:56
  • Ah @JanB.Kjeldsen probably spotted the *actual* problem. To fix, you'll probably have to make multiple columns, join to `DataArea`, hardcode, etc. – Alex Kwitny Jan 28 '20 at 18:19
  • If CurExt() is causing the problem, which kind of makes sense, then I think I can simply add the join into the SQL: "vpst.dataAreaId=T1.dataAreaId". Thank you all for the help! For the record, AX2012R3 w/ mulitple AOSs. – joel Jan 29 '20 at 20:42

0 Answers0