开发者

How to join field values in Views in Dynamics AX 2009

开发者 https://www.devze.com 2023-03-16 14:39 出处:网络
I need to create a View for exporting some Product Data. Ideally I need to merge two fields values (maybe others if possible).

I need to create a View for exporting some Product Data. Ideally I need to merge two fields values (maybe others if possible).

I know SQL in AX is not really proper SQL as I've tried:

Select field1 + field2 from table

Which should work and it doesn't

I have a feelin开发者_开发技巧g I could this with a method in the View, but I've never done this before and I can't find any decent examples anywhere.

Is what I want to do even possible, and if so how would I do it?

Edit

The reason I'm doing this is because I've started using Magento. Its not properly integrated with AX so I was going to create a view with all the data about a product and then do a manual import into Magento.

I want to combine the the SKU of the product with the color id or size id.

So PP1234 and BLU would become PP1234-BLU


try that

 select CAST(field1 AS varchar(number_characters)) 
 + CAST(field2 AS varchar(number_characters))
 from table


You can probably create a staging table, which you would be able to use for export, if it suits your purpose...

static void Test(Args _args)
{
    InventTable inventTable;
    StagingTable stagingTable;
    ;

    ttsbegin;

    insert_recordset stagingTable (ItemId, Field1, Field2)
        select ItemId, SourceField1, SourceField2 from inventTable;

    update_recordset stagingTable
        setting Field1 = stagingTable.Field1 + inventTable.SourceField2,
                Field2 = -stagingTable.Field2 + inventTable.SourceField1
    join inventTable
        where inventTable.ItemId == stagingTable.ItemId;

    ttscommit;
}


From looking around through the little amount of Documentation there is about Dynamics AX I don't think this can be done.

Seems strange the little amount of SQL you can do.


You don't mention why you want to add those two fields together, but if it is merely for presentation, then this can easily be solved by using a display method on the table instance.

public Amount myCustomMethod()
{
    return this.fieldA + thisfieldB;
}

Since you're using X++, and you're doing exporting, I don't understand why you can't do the calculation as a part of the export.

Hope this helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号