How to copy data with translation


#1

Hi!

I have two tables in UB, both contains data translated to another language. I need to copy data from one table to another including translated data.
I’m trying to do the following, but only data in main language is copied:

    var
        store = new TubDataStore('table_Tgt'),
        templateItems = UB.Repository('table_Src')
            .attrs('A', 'B', ....)
            .select()
....
    templateItems.first();
    while (!templateItems.eof) {
        store.run('insert', {
            execParams: {
                ParameterA: templateItems.get('A'),
                ParameterB: templateItems.get('B'),
......
            }
        });
        templateItems.next();
    }

#2

To read multi-language data use a attribute suffix _langCode^. In your sample to read both default user language and English translation:

....
   templateItems = UB.Repository('table_Src')
     .attrs('A', 'A_en^', 'B', 'B_en^' ....)
     .select()
....
    templateItems.first();
    while (!templateItems.eof) {
        store.run('insert', {
            execParams: {
                ParameterA: templateItems.get('A'),
                'ParameterA_en^': templateItems.get('A_en^'), 
                ParameterB: templateItems.get('B'),
                ParameterB_en^: templateItems.get('B_en^'),
......
            }
        });
        templateItems.next();
    }