- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2024 11:06 PM
Hello everyone,
I have a requirement to display a message on the “csm_contact” page when a user clicks on the Disable Login / Enable Login link, similar to when g_form.addInfoMessage() is used in a Catalog Item.
I have tried adding gs.addInfoMessage() and g_form.addInfoMessage() in the Client controller of the widget that cloned the “Contact Roles” widget, but no message is displayed.
Here is the code I tried.
function ($scope, $uibModal, $window, spAriaUtil, $timeout) {
var c = this;
var instance;
$scope.editRoles = function() {
$scope.modalInstance = $uibModal.open({
templateUrl: 'addContactRoleModal',
size: 'lg',
scope: $scope
});
$scope.modalInstance.rendered.then(function() {
var modal = $('div.modal');
modal.attr('aria-labelledby','modal-title');
modal.find('#closeContactRoleModal').focus();
});
};
c.lock = function(lock) {
g_form.addInfoMessage('Example Text'); // Added code
$scope.data.action = 'lock';
$scope.data.lock = lock;
$scope.server.update().then(function(response) {
if(response.status == 'success') {
var infoMessage = lock? "${Login disabled}": "${Login enabled}";
var focusLinkId = lock? "enable_login": "disable_login"
spAriaUtil.sendLiveMessage(infoMessage);
$timeout(function() {
$("#" + focusLinkId).focus();
}, 1000);
}
});
};
c.cancel = function() {
$window.location.reload();
$scope.modalInstance.close();
};
}
Is there any way to implement the above requirements?
Any advice is welcome.
Best regards,
Shuto
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2024 11:08 PM
try $scope.page.g_form.addInfoMessage in client controller.
or
try gs.addInfoMessage() in server script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2024 11:08 PM
try $scope.page.g_form.addInfoMessage in client controller.
or
try gs.addInfoMessage() in server script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-05-2024 11:47 PM
Hi Deepak
Thanks for the quick reply.
gs.addInfoMessage() in server script worked fine.
The $scope.page.g_form.addInfoMessage in client controller caused an error.
However, I noticed that by adding spUtil as an argument, the message can also be displayed from the client controller.
I am attaching the code as well so that anyone who stumbles as I did can refer to it.
function ($scope, $uibModal, $window, spAriaUtil, $timeout, spUtil) { // spUtil added
var c = this;
var instance;
$scope.editRoles = function() {
$scope.modalInstance = $uibModal.open({
templateUrl: 'addContactRoleModal',
size: 'lg',
scope: $scope
});
$scope.modalInstance.rendered.then(function() {
var modal = $('div.modal');
modal.attr('aria-labelledby','modal-title');
modal.find('#closeContactRoleModal').focus();
});
};
c.lock = function(lock) {
spUtil.addInfoMessage('### Example Text ###'); // Added code
$scope.data.action = 'lock';
$scope.data.lock = lock;
$scope.server.update().then(function(response) {
if(response.status == 'success') {
var infoMessage = lock? "${Login disabled}": "${Login enabled}";
var focusLinkId = lock? "enable_login": "disable_login"
spAriaUtil.sendLiveMessage(infoMessage);
$timeout(function() {
$("#" + focusLinkId).focus();
}, 1000);
}
});
};
c.cancel = function() {
$window.location.reload();
$scope.modalInstance.close();
};
}