Scripting Solution to disable the Default Payment Method card selection

var paymentInstrumentSearch = search.create({

                            type: 'paymentinstrument', // Adjust this type if needed for payment instrument

                            filters: [

                                ["customer", "anyof", "240114"],

                                "AND",

                                ["isinactive", "is", "F"],

                                "AND",

                                ["formulatext: {default}", "is", "T"]

                            ],

                            columns: ['internalid']

                        });



                        var searchResult = paymentInstrumentSearch.run().getRange({ start: 0, end: 1 });



                        if (searchResult.length > 0) {

                            var paymentInstrumentId = searchResult[0].getValue('internalid');

                            log.error("idfdf", paymentInstrumentId)

                            // Update isdefault field on the specific payment instrument using submitFields

                            record.submitFields({

                                type: 'paymentcard', // Adjust this if needed for your payment instrument type

                                id: paymentInstrumentId,

                                values: {

                                    'isdefault': false

                                },

                                options: {

                                    enableSourcing: false,

                                    ignoreMandatoryFields: true

                                }

                            });

                            // Load the payment instrument record directly

                             var paymentInstrumentRecord = record.load({

                                 type: 'paymentcard', // Replace with actual payment instrument record type

                                 id: paymentInstrumentId,

                                 isDynamic: true

                             });

                             log.error('Success', JSON.stringify(paymentInstrumentRecord));

                            // // Update the isdefault field to false

                             paymentInstrumentRecord.setValue({

                                fieldId: 'isdefault',

                                value: false

                             });



                            // // Save the payment instrument record

                             paymentInstrumentRecord.save({

                                enableSourcing: false,

                                ignoreMandatoryFields: true

                            });

This is the code which is used to disable the selected payment cards from the webstore

Leave a comment

Your email address will not be published. Required fields are marked *