Restrict creation and deletion of customer journeys / smart guides?

Hello Sugar Lovers,

We've setup our client's CRM so that smart guides / customer journeys are created automatically on opportunities and a custom contracts module. So we do not want users to be able to create/delete journeys. 

I can probably prevent deletion via roles, which would suit my needs. But AFAIK roles can't separate create & edit permissions?

In the past, we had hidden the "add journey" button (and template selection) in the widget but that is not very elegant nor actually safe (to put it mildly). That customization broke a few versions back and we did not update it due to other priorities. Now that's back :) 

Any other idea? 

Best regards,
Damien

  • Hi  , 

    Thanks for sharing this information.

    I recommend restricting deletion via roles, as it's a straightforward and effective solution. However, regarding the creation of the SmartGuide, Sugar is using a specific endpoint, "start-cycle," meaning this isn’t a standard create action and won’t be restricted through role settings.

    To disable users ability to create SmartGuides, customisations will be required.
    One potential approach is to extend the following file:

    clients/base/layouts/dri-workflows/dri-workflows.js

    In this file, you could add a condition to check if the user is an administrator before executing the logic that initiates a new SmartGuide. You could then display a message to non-admin users, informing them that this option is only available for administrators.




    Would this solution work for you? You can also adjust the logic and messaging to block all creations if that better suits your needs.


    Please refer to my example code for guidance.


    //file path custom/clients/base/layouts/dri-workflows/dri-workflows.js
    ({
        extendsFrom: 'DriWorkflowsLayout',
    
        initialize: function(options) {
            this._super('initialize', [options]);
    
        },
    
        startJourneyClicked: function(model) {
            //Changed the function here to restrict the start-cycle only to admin users. 
            let isSysAdmin = (app.user.get('type') === 'admin');
    
            if (_.isEmpty(model.get('dri_workflow_template_id')) || this.startingJourney || !isSysAdmin) {
                if (!isSysAdmin) {
                    console.warn('Warning: User is not an admin and cannot start the journey.');
                    app.alert.show('not_admin_error', {
                        level: 'error',
                        messages: 'Only admin users can start journeys manually.',
                        autoClose: true,
                    });
                }
                return;
            }
    
            this.startingJourney = true;
    
            let url = app.api.buildURL(model.module, 'customer-journey/start-cycle', {
                    id: this.context.get('parentModel').get('id'),
                },
                {
                    template_id: model.get('dri_workflow_template_id'),
                }
            );
    
            this.$('.dri-workflows-actions-spinner').removeClass('hide');
            model.set({
                'dri_workflow_template_id': '',
                'dri_workflow_template_name': '',
            });
    
            this.disablingJourneyAndStartLoading();
    
            app.api.call('create', url, null, {
                success: _.bind(this.createJourneySuccess, this),
    
                error: function(result) {
                    app.alert.show('error', {
                        level: 'error',
                        messages: result.message,
                        autoClose: true,
                    });
                },
    
                complete: _.bind(function() {
                    this.startingJourney = false;
                    this.$('.dri-workflows-actions-spinner').addClass('hide');
                    this.$('.customer-journey-loading-div').remove();
                    this.$el.children().fadeTo('slow', 1);
                }, this),
            });
        }
    });



    Let me know if this helps. 

    Cheers, 

    André