Change the color of the of the workflow buttons in user event script

  let color, buttonId = [];

                    color = ‘ #008000’;

                 

                    buttonId.push(‘custpageworkflow770’);

                    buttonId.push(‘custpageworkflow771’);

                    buttonId.push(‘secondarycustpageworkflow770’);

                    buttonId.push(‘secondarycustpageworkflow771’);

                    let script = changeButtonColor(color, buttonId);

                    // Inject the script into the form

                    scriptContext.form.addField({

                        id: ‘custpage_customscript’,

                        type: ‘inlinehtml’,

                        label: ‘Custom Script’

                    }).defaultValue = script;

const changeButtonColor = (color, buttonIds) => {

            try {

                // Creating a jQuery script string to be inserted into the HTML

                let buttons = buttonIds.map(buttonId => `

                   jQuery(function($) {

                      var buttonElement = jQuery(“#${buttonId}“);

                       if (buttonElement.length) {

                        buttonElement.css({ “background-color”: “${color}“, “color”: “white” })

                         .each(function() {

                        this.style.setProperty(‘background-color’, ‘${color}‘, ‘important’);

                        this.style.setProperty(‘color’, ‘white’, ‘important’);

                            });

                     }

                   });

                `).join();

                let script = `<script>${buttons}</script>`;

                return script;

            } catch (error) {

                log.error(“error@renameButton”, error);

            }

        }

Leave a comment

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