Saleslogix/argos-sample

Removing a mobile quick action from account details

Closed this issue · 9 comments

Hello,
I'm sorry, I don't know where to ask a question, so I am posting it here. I do not know how to remove a quick action from the account details in mobile. I tried the below code, but it didn't work. Some help will be greatly appreciated. Thanks.

loadCustomizations: function() {
console.log('Loading Client Customizations');
this.inherited(arguments);
this.registerAccountCustomizations();
},
// Account Customizations
registerAccountCustomizations: function(){

//Remove Add Note
this.registerCustomization('detail', 'account_detail', {
	at: function(row) { return row.name == 'addNote'; },
	type: 'remove'
});

//Remove Promote. 
this.registerCustomization('detail', 'account_detail', {
	at: function(row) { return row.name == 'PromoteAccount'; },
	type: 'remove'
});

//Remove Add Quote.
this.registerCustomization('detail', 'account_detail', {
	at: function(row) { return row.name == 'AddQuote'; },
	type: 'remove'
});

//Remove Add Ticket. 
this.registerCustomization('detail', 'account_detail', {
	at: function(row) { return row.name == 'addTicket'; },
	type: 'remove'
});	

},

The first example is using the wrong row.name. The correct name property value is "AddNoteAction":

See:
https://github.com/Saleslogix/argos-saleslogix/blob/develop/src/Views/Account/Detail.js#LL130C26-L130C26

Here is an example I tested locally removing the schedule activity action:

    console.log('loading customizations');
    this.registerCustomization('detail', 'account_detail', {
      at: function at(row) {
        console.log(`at row ${row.name}`);
        return row.name === 'ScheduleActivityAction';
      },
      type: 'remove',
    });

Within the "at" function, I would add a console.log or console.dir(row) so you can see what it is checking.

Oh, I see what I was doing wrong. I thought the 'action' property was the right value to use. I fixed it and It worked. Thanks a lot!!!

You are welcome! Have a great day.

Thanks, you as well!

I'm sorry, me again. It seems that I can remove any Quick Action listed under the for example src\Views\Contact\Detail.js file (I previously did it for Account). But I cant remove AddOrder quick action for the Contact detail that appears in the src\Integrations\BOE\ContactModule.js file. I used same pattern I did for Account in my project. If I do row.name == 'ViewAddressAction', then both AddQuote and AddOrder get removed. I only need AddOrder removed. Is there a way to do it?

this didnt do it:
this.registerCustomization('detail', 'contact_detail', {
at: function(row) {
return row.name == 'AddOrder'; },
type: 'remove'
});

This is from the ContactModule.js file where I got the row.name from:
/*
* Quick Actions
*/
am.registerCustomization('detail', 'contact_detail', {
at: function at(row) {
return row.name === 'ViewAddressAction';
},
type: 'insert',
where: 'after',
value: [{
name: 'AddQuote',
property: 'NameLF',
label: this.addQuoteText,
iconClass: 'document',
action: '_onAddQuoteClick',
security: 'Entities/Quote/Add',
}, {
name: 'AddOrder',
property: 'AccountName',
label: this.addOrderText,
iconClass: 'cart',
action: '_onAddOrderClick',
security: 'Entities/SalesOrder/Add',
}],
});

It looks like this is a possible bug in our customization code. If a previous customization modifies the layout, the next customization does not see this change, only the original layout. I will dig in a bit more and see if I can resolve it. If not, I can get a prototype modification workaround for you to use instead.

Aw thank you so much. I really appreciate your time and help. Have a great evening.

You can add this to your customization method:

var orig = crm.Views.Contact.Detail.prototype._createCustomizedLayout;
crm.Views.Contact.Detail.prototype._createCustomizedLayout = function _createCustomizedLayout() {
    var customizedLayout = orig.apply(this, arguments);
    if (Array.isArray(customizedLayout)) {
        customizedLayout.forEach(function forEach(row) {
            if (row.name === "QuickActionsSection") {
                row.children = row.children.filter(function filter(child) {
                    return child.name !== 'AddOrder';
                });
            }
        });
    }

    return customizedLayout;
};

This will alter contact detail prototype and allow you to capture the internal call to _createCustomizedLayout(), which is what executes each customization hook and returns the modified layout. This lets you modify what the BOE module inserts prior to rendering.

I confirm it worked fine for me. Thanks a lot for your help! Hoping the rest of the week is great for you.