How create a widget to add accounts to the contacts in CSM portal.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2024 06:26 AM
In csm portal contact page, there is a add roles widget, I want another widget to add account to the contact.
below is the code for contact role widget, please let me know, what changes are needed in this code to add accounts to the contacts?
HTML:
<div ng-if="data.isValid && data.show_config" class="panel panel-default b">
<div class="panel-heading">
<h4 class="panel-title">
${User Management}
</h4>
</div>
<div class="panel-body">
<!-- Edit roles action -->
<div class="m-b-xs" >
<button class="btn btn-default" ng-click="editRoles()">
${Edit Roles}
</button>
</div>
<!-- Enable/Disable login -->
<div class="m-b-xs" >
<button ng-if="c.data.locked" class="btn btn-default" ng-click="c.lock(false)">
${Enable Login}
</button>
<button ng-if="!c.data.locked" class="btn btn-default" ng-click="c.lock(true)">
${Disable Login}
</button>
</div>
</div>
</div>
SERVER
(function($sp, input, data, options) {
if (!gs.hasRole("sn_customerservice.customer_admin")) {
data.show_config = false;
return;
}
data.show_config = true;
data.table = $sp.getParameter("t") || $sp.getParameter("table") || input.table;
data.sys_id = $sp.getParameter("sys_id") || $sp.getParameter("sl_sys_id") || input.sys_id;
var contact = new GlideRecord("customer_contact");
data.isValid = contact.get(data.sys_id);
if (data.isValid && input) {
if (input.action == 'lock') {
contact.setValue('locked_out', input.lock);
contact.update();
data.status = 'success';
} else if (input.action == 'create_login') {
contact.setValue('user_name', input.user_name);
contact.update();
data.status = 'success';
}
}
data.locked = contact.getValue('locked_out') == "1" ? true : false;
//read roles
var gr = new GlideRecord('sys_user_has_role');
gr.addQuery('user', contact.getUniqueValue());
gr.addQuery('inherited', false);
gr.query();
var roles = [];
while(gr.next()) {
var role = gr.getDisplayValue('role');
if (!gs.nil(role))
roles.push(role);
}
data.roles = roles.toString();
var slushbucketParams = {};
var account = contact.account.getRefRecord();
slushbucketParams.roles = roles;
slushbucketParams.partnerAccount = account.getValue('partner') == "1" ? true : false;
data.widgetAddNew = $sp.getWidget('copy_of_contact_role_slushbucket', slushbucketParams); //changed to "copy_of_contact_role_slushbucket" from "contact-role-slushbucket"
})($sp, input, data, options);
CLIENT:
function ($scope, $uibModal) {
var c = this;
var instance;
$scope.editRoles = function() {
$scope.modalInstance = $uibModal.open({
templateUrl: 'addContactRoleModal',
size: 'lg',
scope: $scope
});
};
c.lock = function(lock) {
$scope.data.action = 'lock';
$scope.data.lock = lock;
$scope.server.update().then(function(response) {
});
};
c.cancel = function() {
$scope.modalInstance.close();
};
}
0 REPLIES 0