How to create a popup depending on a status?

Dear community,

I have not yet found what I am looking for and therefore I ask the question at this point:

We have implemented a status field in the Accounts module. There are two statuses (active and idle). We would like a popup to appear when an idle account is opened. This popup should looks like a warning message, contains a text and an OK button.

An example is attached.
Ho can we create such a popup? At first, we only need this Popup, which inly informs the user, that the status is idle.

Many thanks in advance for your support.

Greetings from Berlin, Germany

Martin

Parents
  • To do this, you will need to make a slight customization to the record.js controller file for that module.

    If it doesn't already exist, create the following file:

    <your sugar folder>/custom/modules/Accounts/clients/base/views/record/record.js

    And then you can extend it with your custom function to display some alert or popup when the record view loads the data.

    ({
        extendsFrom: 'RecordView',
        initialize: function (options) {
            this._super('initialize', [options]);
            this.listenTo(this.collection, 'data:sync:complete', this.renameThisFunction);  
            //this function will run once the data has been loaded into the view, so basically, this is the point in time when you want the popup to appear
        },

    renameThisFunction: function() {
        var model = app.controller.context.get('model');
        //you can then get your custom field from the model
        var yourCustomDataField = model.get('your_custom_data_field_c');
        //this will only work if the vardefs
        //and the fields_meta_data table entry have been set up correctly!
        
        if(yourCustomDataField === 'idle') {
            app.alert.show('add_unique_message_id_here', {
                level: 'error',
                messages: 'Your Error message here',
                autoClose: false
            });

        }
    }

    })

    Although this way you won't have an OK button, just an X to close as it is just an alert.

    If you need a fancier pop-up, with high customizability instead of the standard alert, you could use the Base Edit Modal View instead.

Reply
  • To do this, you will need to make a slight customization to the record.js controller file for that module.

    If it doesn't already exist, create the following file:

    <your sugar folder>/custom/modules/Accounts/clients/base/views/record/record.js

    And then you can extend it with your custom function to display some alert or popup when the record view loads the data.

    ({
        extendsFrom: 'RecordView',
        initialize: function (options) {
            this._super('initialize', [options]);
            this.listenTo(this.collection, 'data:sync:complete', this.renameThisFunction);  
            //this function will run once the data has been loaded into the view, so basically, this is the point in time when you want the popup to appear
        },

    renameThisFunction: function() {
        var model = app.controller.context.get('model');
        //you can then get your custom field from the model
        var yourCustomDataField = model.get('your_custom_data_field_c');
        //this will only work if the vardefs
        //and the fields_meta_data table entry have been set up correctly!
        
        if(yourCustomDataField === 'idle') {
            app.alert.show('add_unique_message_id_here', {
                level: 'error',
                messages: 'Your Error message here',
                autoClose: false
            });

        }
    }

    })

    Although this way you won't have an OK button, just an X to close as it is just an alert.

    If you need a fancier pop-up, with high customizability instead of the standard alert, you could use the Base Edit Modal View instead.

Children