Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

service portal sn-avatar

dheeraaj
Giga Expert

Hi All,

Need help in using the <sn-avatar>. See the attached image. No matter which user I add, it is always displaying the current user image. Not sure where I am going wrong. 

I have used the below code: 

HTML: 

<span class="navbar-avatar">
<sn-avatar class="avatar-small-medium" primary="userID" show-presence="false" />
</span>

client controller:

$scope.userID = $scope.user.sys_id;

 

Help is appreciated.

 

Regards,

Dheeraj

1 ACCEPTED SOLUTION

updated client controller code. 

 

function($scope, spUtil, $sce, $rootScope, $timeout) {
var c = this;

$("#share-link-input")[0].value = window.location;
c.data.userList = [];
c.data.action = "";

$scope.shareuser = {
displayValue: '',
value: '',
name: 'shareuser'
};

$scope.isUserListEmpty = function() {
return c.data.userList.length < 1;
};

c.select = function() {
$("#share-link-input").select();
};

c.copyURL = function() {
c.select();
document.execCommand("copy");
$(".share-custom-message").fadeToggle();
setTimeout(function(){
$(".share-custom-message").fadeToggle();
},500);
};

c.removeUser = function(index) {
c.data.userList.splice(index,1);
};

c.submit = function() {
c.data.action = "submit";

var url = $("#share-link-input")[0].value;
c.data.document_id = url.slice(url.indexOf("sys_id=")+7);
c.data.message = $("#share-note-input")[0].value;
c.data.urlType = $("#url-type")[0].value;

c.server.update().then(function(response) {
spUtil.update($scope);
c.data.action = '';
$("#share-note-input")[0].value = '';
});
};

$scope.$on("field.change", function(evt, parms) {
if(parms.field.name == 'shareuser') {
$scope.userID = parms.newValue;
c.data.userId = parms.newValue;
c.data.action = "addUser";
}
if(c.data.action == '') {
return;
}

c.server.update().then(function(response) {
spUtil.update($scope);
c.data.action = '';
$scope.shareuser = {
displayValue: '',
value: '',
name: 'shareuser'
};
});
});

}

 

If my answer helped you, mark it as correct and helpful. 

View solution in original post

5 REPLIES 5

Thanks Harsha. I see that when adding more users to the list, the existing avatars are changing as that of last added.

 

Regards,

Dheeraj