I can't change field mapping order. Is this bug?

I tried changing the order array of fieldMapping, but it does not seem to take effect.

This is a screen recording:
https://www.dropbox.com/s/vawqnyafhtvjx6g/Screencast%20from%2003-30-2022%2004%3A39%3A43%20PM.webm?dl=0

Is this bug?

Thanks

Hello Tan,

I tried doing it myself, but I can’t recreate the issue.
Is there any customization (Javascript, plugin, etc) in this app?
If so, could you explain it in detail?

Best,
Chris

Hello Chris,

This app is not any customization, and the issue occured on other apps (have customization) in this domain. I tried change it with api, but not success.

Thank you for your support

Hi Tan,

Could you tell me which fields you are specifying for the field mappings?
It might be due to fields that are not allowed to be specified for field mappings selected.

Fields That Can Be Specified for “Field Mappings”
https://get.kintone.help/k/en/id/040546.html

Also, could you kindly elaborate on what type of issue you will run into by not being able to adjust the orders of the fields?
I am currently checking this matter on my end as well. If I find anything, I will update you.

Thank you,
Sean

Hi Sean,

Fields specified for filed mappings is allowed. 

I am creating app to deploy other apps. The issue occured when i check different between app on dev environment with app on product environment. 

Thank you,

Tan

Hello Tan,

Thank you for verifying that all the fields specified in the lookup field mapping are allowed (as specified in the Fields That Can Be Specified for “Field Mappings” help doc).

Please provide more information regarding the app in question.

  1. What do you mean by “I am creating app to deploy other apps”?
  2. Does this “lookup field failing to update” error occur only in your production environment? Or does this error occur in both your dev and production environments?
  3. Have you added a JS customization on either App being connected by the lookup field mapping?

Thank you for your time,
Genji

Hello Genji,

I answer each your question:

  1. I created a app. This app will create or migrate app for product environment from app on develop environment.

  2. When i change order field mapping then app updated, but order field mappings not change.

  3. Yes, I have added JS customiztion on a app.

Thank you,

Tan

 

Thank you for your reply, Tan.
Please verify that the JS customization on both Apps does not interfere with the fields used in the lookup field mapping.

If it does, please share the code so we can recreate the bug in our environments.

Thank you for your time,

Genji

I have catched event change on the lookup field mapping.

(function() {
    'use strict';
    const auto_fill = [
        '取引先コード', 'スキーム',
        '振込手数料負担', 'サービス利用料負担'
    ]

    kintone.events.on('app.record.create.show', function(event) {
        var record = event.record;
        // mutation
        const table_record = document.querySelector('table.subtable-gaia tbody')
        const config = {childList: true};
        const callback = function(mutationsList, observer) {
            // Use traditional 'for loops' for IE 11
            for(const mutation of mutationsList) {
                if (mutation.type === 'childList') {
                    let checkboxes = table_record.querySelectorAll('input[type=checkbox]')
                    for (let i=0; i<checkboxes.length; i++) {
                        checkboxes[i].disabled = true
                    }
                }
            }
        };
        const observer_print = new MutationObserver(callback);
        observer_print.observe(table_record, config);
        // end mutation
        kintone.app.record.setFieldShown('入金履歴', false);
        disable_fields(record, disable_when_create);
        disable_condition_fields(record);
        show_condition_fields(record);
        return event;
    });

    kintone.events.on('app.record.create.change.数値', function(event) {
        var record = event.record;
        var table_deposit = record['入金履歴'].value
        var row = event.changes.row
        var sum = 0
        for (let i=0; i<table_deposit.length; i++) {
            sum += Number(table_deposit[i].value['数値'].value) || 0
        }
        record['入金額'].value = sum
        record['残高'].value = record['合計'].value - sum
        row.value['入金チェック'].disabled = true
        return event
    });

    kintone.events.on('app.record.create.change.請求先会社名', function(event) {
        var record = event.record;
        auto_fill.forEach(e => record[e].disabled = false)
        return event
    });

    kintone.events.on('app.record.create.change.sub_入金日', function(event) {
        let record = event.record;
        let row = event.changes.row
        record['入金日'].value = row.value['sub_入金日'].value
        return event
    });
    
    var change_date = [
        'app.record.create.change.サービス開始日',
        'app.record.create.change.サービス締日'
    ]

    kintone.events.on(change_date, function(event) {
        var record = event.record;
        validate_date(event, record);
        return event
    });
    kintone.events.on('app.record.create.change.スキーム', function(event) {
        var record = event.record;
        disable_condition_fields(record);
        show_condition_fields(record);
        return event
    });
    var calculate_total = [
        'app.record.create.change.スキーム',
        'app.record.create.change.固定利用料',
        'app.record.create.change.振込金額',
        'app.record.create.change.振込手数料',
        'app.record.create.change.サービス利用料',
        'app.record.create.change.その他1',
        'app.record.create.change.その他2',
        'app.record.create.change.その他3',
        'app.record.create.change.その他4',
        'app.record.create.change.振込手数料負担',
        'app.record.create.change.サービス利用料負担',
        'app.record.create.change.件数'
    ]

    kintone.events.on(calculate_total, sum_fee);

    var calculate_other_amount = [
        'app.record.create.change.その他項目1',
        'app.record.create.change.その他項目2',
        'app.record.create.change.その他項目3',
        'app.record.create.change.その他項目4',
    ]

    kintone.events.on(calculate_other_amount, function(event) {
        let record = event.record;
        let varible = event.type.slice(-1)
        let value = 'その他' + varible
        if (!record['その他項目' + varible].value) {
            record[value].value = 0
            record[value].disabled = true
        } 
        else {
            record[value].disabled = false
        }
        return event
    });

    kintone.events.on('app.record.create.change.入金履歴', function(event) {
        let record = event.record;
        let table_deposit = record['入金履歴'].value
        if (table_deposit[0].value['入金チェック'].disabled) {
            for (let row of table_deposit) {
                row.value['入金チェック'].disabled = true
            }
        }
        return event
    });


    kintone.events.on('app.record.create.submit', function(event) {
        var record = event.record;
        var code_id

        if (!record['請求書番号'].value) {
            var issue_date = !record['請求書発行日'].value ? moment(record['請求書発行日'].value): moment(new Date());
            var date = issue_date.format('YYYY') + issue_date.format('MM');
            var company_code = record['企業コード'].value;
            code_id = date + '-' + company_code.slice(2, 9)
        }
        else {
            code_id = record['請求書番号'].value.slice(0, 14)
        }

        var this_body = {
            'app': event.appId,
            'query': `企業コード = "${record['企業コード'].value}" order by $id desc limit 100`,
            'fields': ["$id","請求書番号"]
        };
        var that_body = {
            'app': send_data_to_appId,
            'query': `請求書番号 = "${record['企業コード'].value}" order by $id desc limit 100`,
            'fields': ["$id","請求書番号"]
        };
        validate_business_code(event, record);
        validate_date(event, record);

        return kintone.api('/k/v1/records', 'GET', this_body).then(function(resp1) {
            var first_resp = 0
            resp1.records.forEach(thisrecord => {
                if (thisrecord['請求書番号'].value.indexOf(code_id) >= 0) {
                    let num = Number(thisrecord['請求書番号'].value.slice(-2,))
                    if (first_resp < Number(thisrecord['請求書番号'].value.slice(-2,))) {
                        first_resp = num
                    }
                }
            })
            
            return kintone.api(kintone.api.url('/k/v1/records', true), 'GET', that_body).then(function(resp2){
                var second_resp = 0
                    resp2.records.forEach(thisrecord => {
                        if (thisrecord['請求書番号'].value.indexOf(code_id) >= 0) {
                            let num = Number(thisrecord['請求書番号'].value.slice(-2,))
                            if (second_resp < Number(thisrecord['請求書番号'].value.slice(-2,))) {
                                second_resp = num
                            }
                        }
                    })
                record["発行番号"].value = set_issue_No(first_resp, Number(second_resp));
                record["請求書番号"].value = code_id + '-' + record["発行番号"].value;
                if (Number(record["発行番号"].value) > 1){
                    return Swal.fire({
                        title: '<p>すでに請求書データは存在します </br> 再発行しますか?</p>',
                        icon: 'question',
                        showCancelButton: true,
                        focusConfirm: false,
                        confirmButtonText: '再発行',
                        confirmButtonColor: '#3498db',
                        cancelButtonText:'キャンセル',
                    }).then(function(result) {
                        if (!result.value) {
                            return false;
                        }
                        return event;
                    }
                )}
                return event;
            }, function(error) {
                return false;
            })
        }, function(error) {
            return false;
        });
    });

    function validate_business_code(event, record) {
        if (!/^[0-9A-Za-z]+$/.test(record['企業コード'].value)) {
            event.error = "英数字(小文字含む)で9桁以上を入力してください";
        }
    }

    function validate_date(event, record) {
        if (record['サービス締日'].value !== undefined) {
            var start_date = moment(record['サービス開始日'].value).format('YYYY-MM-DD');
            var end_date = moment(record['サービス締日'].value).format('YYYY-MM-DD');

            if (moment(start_date).isAfter(end_date)) {
                event.error = "サービス締日は「サービス開始日」以降に設定してください";
            }

            if (moment(start_date).isSame(end_date)) {
                event.error = "サービス締日は「サービス開始日」以降に設定してください";
            }
        }
    }
})();

Thank you,

Tan

Hello Tan,

I’m not sure what the problem is,
but is it possible for you to change the field mappings to completely different fields?

If so, after you change the field mappings to the different fields, could you put the fields back but in the proper order that you wanted to be?

Thank you,
Chris