I need to do something like the below as mentioned by another user in 2018. The user has also given the solution of what to do. But I need to know where to put the solution code. P
Please some one let me know where should I put the suggestion solution code, which is explained in detail after the question below.
"After creating the custom rowActionMenu buttons, I added code to pass in a {beforeOpen: function() {}} to the menu object. " - Where do I put this?
Thank you
Question:
I want to enable/disable a custom Approve button. I only want the Approve button to be enabled for rows that require approval. Clicking the actions menu does not select the record. I need to know what event I can use to perform the check so that the button is only enabled if it is applicable for the specific row it is being called on.
Suggested Solution by other user:
After creating the custom rowActionMenu buttons, I added code to pass in a {beforeOpen: function() {}} to the menu object.
rowActionMenuObj$.menu({beforeOpen: function(event, ui) {
var lRow$ = view.view$.find('.is-active').closest('tr');
var record = view.getContextRecord(lRow$)[0];
var recordId = view.model.getValue(record, "EXPENSES_ID");
var recordStatusCode = view.model.getValue(record, "RECORD_STATUS_CODE");
if (isApprover && (recordStatusCode == 'N' || recordStatusCode == 'C')) {
var approveExpensesItem = rowActionMenuObj$.menu("find", "approve-expense");
approveExpensesItem.disabled = false;
} else {
var approveExpensesItem = rowActionMenuObj$.menu("find", "approve-expense");
approveExpensesItem.disabled = true;
}
}});