I want to change the list of status on the Case create view based on a selection made from a drop down list and the role of a user. I currently have code running which should do this. It will successfully fire when the form is initiated but it does not fire when the triggering field is changed. I want to change the status list each time the et_case_type field is changed.
initialize: function (options) {
this._super("initialize", [options]);
//this.checkRole();
this.model.on('change:et_case_type',this.checkRole(), this);
},
checkRole: function() {
var self = this;
app.api.call('read', app.api.buildURL('Users/check_role_membership/' + encodeURIComponent('Archive Cases')),
null,
{
success: function(res) {
if (res.isEnabledRole && !res.isAdmin) {
var case_statuses = app.lang.getAppListStrings('case_status_dom');
var isFCST = app.user.get('roles').indexOf("Fleet Customer Services");
var isMobile = false;
if(self.model.get('et_case_type') == 1 || !self.model.get('et_case_type'))
{
isMobile = true;
};
if(isFCST != -1 && isMobile != true)
{
delete case_statuses['Closed_for_Customer'];
delete case_statuses['Closed_for_Ops'];
delete case_statuses['Closed_for_Kwikfit'];
}
delete case_statuses['Closed_for_Kwikfit'];
self.model.fields['status'].options = case_statuses;
self.render();
}
},
error: function(error) {}
}
)
},