11 Replies Latest reply on Dec 11, 2018 6:10 AM by John Haddad

    Chat and Social not working

    John Haddad Expert

      Hi

      2018.3 Version '

       

      i used  design transfer and import the Chat and Social Module

      I have the instances name:
      ServiceDesk.WebAccess for web-AccessWorkspace for Bridge-IT

       

      i follow the steps to edit the Chat.html and Chat.JS

      as follow :

       

      1-  i copy the folder ( Social ) and replace the original location under BridgeIT folder
      location C:\Program Files (x86)\LANDESK\BridgeIT\

       

      2- i edit Chat.HTML file :

      ListPendingChats = 'http://WIN-60O5M0GN492/Workspace/Social/Chat.html?session="client":"BIT","session":"pending"';

                and

      </script>
      
      
      <link type="text/css" media="screen,print" rel="Stylesheet" href="/ServiceDesk.WebAccess/wd/Stylesheet/All.rails"/>
      <script type="text/javascript" src="javascripts/prototype.js"></script>
      

       

      3- i edit the chate.Js:

      // Site Constants
      BridgeIT = 'Workspace'
      WebAccess = 'ServiceDesk.WebAccess'
      

       

      4- Now i have added URL link in Gadgets in workspace :

       

       

      once i click on any of them it open another tab and show blank content :

       

      any Idea For help !

        • 3. Re: Chat and Social not working
          Julian Wigman ITSMMVPGroup

          John.Moha

           

          Sorry John, I try to avoid using some of the content packs like this that have javascript code in them because they are unsupported by Ivanti and I dont want to put my customers in a position where Ivanti Support are unable or unwilling to help if there are any issues.

           

          Julian

          • 4. Re: Chat and Social not working
            John Haddad Expert

            but its on community and the PDF for implementing this is from ivanti

             

            i can't understand this really

            • 5. Re: Chat and Social not working
              MotazAlqaissi ITSMMVPGroup

              Hi Haddad,

               

              I found the below file while looking in my old files. Make sure to backup your application and database prior doing any changes. Note that this is not supported by Ivanti.

               

              function Initialise() {
              // Unsupported Chat API Example Script
              // For Social domain cloned from Call
              // 28Sept2012
              //
              // set strings on page
              $('ChatTitle').innerHTML = EndUserPageTitle;
              document.title = EndUserPageTitle;
              $('StatusSpan').innerHTML = LoadingText;
              $('LaunchChatTextSpan').innerHTML = LaunchChatText;
              $('LaunchChatTextSpanBIT').innerHTML = LaunchChatText;
              
              $('NewChatSubmitButton').value = NewChatSubmitText;
              $('SendCommentButton').value = SendCommentText;
              $('SendCommentButtonBIT').value = SendCommentText;
              $('EndChatButton').value = EndChatText;
              $('EndChatButtonBIT').value = EndChatText;
              
              
              $('SessionEndedSpan').innerHTML = SessionEndedText;
              $('StartNewChatLink').innerHTML = StartNewChatLinkText;
              $('StartNewChatLinkBIT').innerHTML = StartNewChatLinkText;
              
              // Site Constants
              BridgeIT = '/LDSD_2017.BridgeIT'
              WebAccess = '/LDSD_2017.Webacceess'
              
              // timer settings (1000 = 1 second)
              
              GetCommentsInterval = 2000;
              GetPendingSessionsInterval = 3000;
              GetActiveSessionsInterval = 3000;
              
              // metadata constants
              SocialModule = '_Social';
              ChatObject = 'Conversation';
              CommentObject = '_ChatComment';
              CommentIdAttribute = 'Id';
              CommentTextAttribute = '_Comment1';
              CommentToParentRelationship = '_Conversation1';
              
              
              ChatProcess = 'NewProcess1';
              WaitingResponseStatus = 'WaitingResponse';
              InProgressStatus = 'InProgress';
              RespondAction = 'Respond';
              AddCommentAction = 'AddChatComment';
              EndChatAction = 'EndChat';
              
              
              SessionTitle = 'Web Chat Conversation'; // must use %20 for spaces.
              
              ClassName = SocialModule + '.' + ChatObject;
              CommentClassName = SocialModule + '.' + CommentObject;
              
              LastChatDescription = '';
              
              document.addEventListener('DOMContentLoaded',function(){
              
              if(!Notification){
              return;
              }
              if(Notification.permission !== "granted"){
              
              Notification.requestPermission();
              }
              });
              
              
              LoadChat();
              }
              
              
              function notifyMe(TitleText,IconURL,BodyText){
              if(Notification.permission !== "granted")
              Notification.requestPermission();
              else{
              var notification = new Notification(TitleText,{
              icon:IconURL,
              body:BodyText});
              
              
              notification.onclick = function(){
              window.focus();
              this.cancel();
              };
              }
              
              
              
              }
              
              
              function LoadChat() {
              $('ChatSessionDiv').hide();
              $('ChatSessionDivBIT').hide();
              $('NewChatDiv').hide();
              $('NewChatDivBIT').hide();
              
              
              SessionGuid = null;
              LastCommentID = 0;
              GetCommentsTimer = null;
              IsAnalystSession = false;
              
              
              URL = '{' + GetParameter('session') + '}';
              URL = decodeURI(URL).evalJSON();
              
              SessionParameter = URL.session;
              ClientType = URL.client;
              ResizePendingBIT = URL.resizePendingBIT;
              if(ResizePendingBIT == 1){
              window.open('Chat.html?session=%22client%22:%22BIT%22,%22session%22:%22pending%22','BridgeITChat','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=550,height=600');
              self.close();
              }
              ResumeOption = null;
              if(URL.hasOwnProperty('resume')){
              ResumeOption = true;
              }else{
              ResumeOption = false;
              }
              
              //console.log(SessionParameter);
              //console.log(ClientType);
              //console.log(ResumeOption);
              
              if (SessionParameter != null) {
              if (SessionParameter.toLowerCase() == 'pending') {
              // pending requests list
              $('TitleDiv').hide();
              if (ClientType == 'wa'){
              GetPendingSessions();
              setInterval('GetPendingSessions()', GetPendingSessionsInterval);
              }else{
              GetPendingSessionsBIT();
              setInterval('GetPendingSessionsBIT()', GetPendingSessionsInterval);
              }
              }else if(SessionParameter.toLowerCase() == 'active'){
              $('TitleDiv').hide();
              if (ClientType == 'wa'){
              GetActiveSessions();
              setInterval('GetActiveSessions()', GetActiveSessionsInterval);
              }else{
              // possible enhancement for bridgeIT
              ;
              }
              }
              else if (SessionParameter.toLowerCase() == "launch") {
              // show launch page
              $('TitleDiv').hide();
              $('StatusDiv').hide();
              if (ClientType == 'wa'){
              $('LaunchChatDiv').show();
              }else if(ClientType == 'BIT'){
              //$('LaunchChatDivBIT').show();
              window.open('Chat.html?session=%22client%22:%22BIT%22','BridgeITChat','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=550,height=600');
              self.close();
              //open(location, '_self').close();
              
              }
              }
              else {
              // analyst is responding/opening
              $('ChatTitle').innerHTML = AnalystPageTitle;
              document.title = AnalystPageTitle;
              IsAnalystSession = true;
              if (ClientType == 'wa' && !ResumeOption){
              new Ajax.Request(WebAccess + '/object/invokeFunction.rails?class_name=' + ClassName + '&function_name=' + RespondAction + '&key=' + SessionParameter,
              {
              onSuccess: function(response) { RespondSession_Response(response, true) },
              onFailure: function(response) { RespondSession_Response(response, false) }
              });
              }else if(ClientType == 'wa' && ResumeOption){
              RespondSession_Response(null, true);
              }
              else{
              
                  
              new Ajax.Request(BridgeIT + '/api/object?class_name=' + ClassName + '&key=' + SessionParameter + '&function_name=' + RespondAction, 
              {
              method: 'post',
              //parameters: Object.toJSON(formVals),
              onSuccess: function(response) { RespondSession_ResponseBIT(response); },
              onFailure: function(response) { Ajax_Failed(ErrorStartingSession, response); }
              });
              
              }
              }
              }
              
              
              else {
              if (ClientType == 'wa'){
              // new session, check for existing chat session for this end user
              var url = WebAccess + '/Query/List.rails?class_name=' + ClassName + '&attributes=Id%2CGuid&cns=Status.Name-i-0-_a_RaiseUser-icu&c0=' + WaitingResponseStatus + '%2C' + InProgressStatus + '&page_size=1';
              new Ajax.Request(url, {
              onSuccess: function(response) { CheckSessions_Response(response) },
              onFailure: function(response) { Ajax_Failed(ErrorCheckingExistingSessions, response) }
              });
              }else{
              // new session, check for existing chat session for this end user
              var url = BridgeIT + '/api/query?class_name=' + ClassName + '&attributes=Guid&cns=Status.Name-i-0-_a_RaiseUser-icu&c0=' + WaitingResponseStatus + '%2C' + InProgressStatus + '&page_size=1';
              new Ajax.Request(url, {
              method:'get',
              onSuccess: function(response) { CheckSessions_ResponseBIT(response)},
              onFailure: function(response) { Ajax_Failed(ErrorCheckingExistingSessions, response) }
              });
              }
              }
              
              
              }
              
              
              function GetPendingSessionsBIT(){
              
              var url = BridgeIT + '/api/query?class_name=' + ClassName + '&query=_ChatRequests&sort_by=CreationDate%20desc&enable_launch=true';
              
              new Ajax.Request(url, {
              method:'get',
              onSuccess: function(response) { GetPendingSessions_ResponseBIT(response)  },
              onFailure: function(response) { Ajax_Failed(ErrorGettingPendingSessions, response)  }
              });
              }
              
              
              function GetPendingSessions() {
              var url = WebAccess + '/Query/List.rails?class_name=' + ClassName + '&attributes=Guid%2CRaiseUser%2CRaiseUser.Guid%2CRaiseUser._ADCountry%2CRaiseUser._ADState%2CCreationDate%2CDescription&cns=Status.Name-e-0-&c0=' + WaitingResponseStatus + '&sort_by=CreationDate';
              new Ajax.Request(url, {
              onSuccess: function(response) { GetPendingSessions_Response(response) },
              onFailure: function(response) { Ajax_Failed(ErrorGettingPendingSessions, response) }
              });
              }
              
              
              function GetActiveSessions() {
              //var url = WebAccess + '/Query/List.rails?class_name=' + ClassName + '&query=_MyActiveChats&attributes=Guid%2CRaiseUser%2CRaiseUser.Guid%2CCreationDate%2CDescription&cns=Status.Name-e-0_a_LatestAssignment.User-icu&c0=' + InProgressStatus + '';
              var url = WebAccess + '/wd/Query/List.rails?class_name=' + ClassName + '&query=_MyActiveChats&attributes=Guid%2CRaiseUser%2CRaiseUser.Guid%2CCreationDate%2CDescription&cns=LatestAssignment.User-icu_a_Status-e-0&c0=c312093d-4437-45e3-924a-8c0930d65729';
              new Ajax.Request(url, {
              onSuccess: function(response) { GetActiveSessions_Response(response) },
              onFailure: function(response) { Ajax_Failed(ErrorGettingActiveSessions, response) }
              });
              }
              
              
              function GetPendingSessions_ResponseBIT(response){
              $('StatusDiv').hide();
              ResetError();
              var json = response.responseText.evalJSON();
              var html = '';
              var LastTitle = '';
              var LastDesc = '';
              if (json.DataRows.length > 0) {
              html = "<div id=TitleDiv style='   font-size: 2rem; line-height: 2.5rem; height: 2.5rem;color: #333; border-bottom: 1px solid #333;font-family:\"Roboto-Light\",\"Microsoft YaHei New\",\"Microsoft Yahei\",SimSun,STXihei,Arial,Helvetica Neue,sans-serif; -webkit-margin-before: 0.67em;-webkit-margin-after: 0.67em;-webkit-margin-start: 0px;-webkit-margin-end: 0px;'> <span class="contentTitleText" id=ChatTitle>Pending Chat Requests</span></div><div id=StatusDiv class="contentHeader"><span id=ErrorSpan style=display:none></span><span id=StatusSpan style='font-family: \"Roboto-Light\",\"Microsoft YaHei New\",\"Microsoft Yahei\",SimSun,STXihei,Arial,Helvetica Neue,sans-serif;font-size: 1.5rem; font-weight: 300; line-height: 120%; color: #333;'>Pending Chat Requests</span></div>";
              json.DataRows.each(function(item) {
              
              html += '<table cellpadding=0 cellspacing=0 border=0 class="list" width=100%>';
              html += '<div><table><tr>';
              
              html += '<td><b>' + item.Values.RaiseUser.Title + '</b> - ' + item.Values.CreationDate + '<br>' + item.Values.Description + '</td>';
              
              html += '<td><a href="" onclick="window.open(\'Chat.html?session=%22session%22:%22' + item.Key + '%22,%22client%22:%22BIT%22';
              
              html += '\',\'_blank\',\'toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=550,height=600\'); return false">';
              html += '<img src="respond.png" height="40px" border=0 /></a></td>';
              //html += '<td><img src="logincident_dis.jpg" height="40px" border=0 /></td>';
              //html += '<td><img src="closechat_dis.jpg" height="40px" border=0 /></td>';
              html += '</tr>';
              //html += '<tr>';
              //html += '<td colspan="4"></td>';
              html += '</table></div>';
              
              
              html += '</span></td></tr>';
              LastTitle = item.Values.RaiseUser.Title;
              LastDesc = item.Values.Description;
              
              });
              if(LastDesc !== LastChatDescription){
              LastChatDescription = LastDesc;
              notifyMe(LastTitle,"Chat-icon.png",LastDesc);
              }
              }else html = '<div class="contentHeader">' + NoPendingRequestsText + '</div>';
              $('PendingChatsDiv').innerHTML = html;
              }
              
              
              function GetPendingSessions_Response(response) {
              $('StatusDiv').hide();
              ResetError();
              var json = eval('(' + response.responseText + ')');
              var html = '';
              if (json.objects.length > 0) {
              html = '<table cellpadding=0 cellspacing=0 border=0 class="list" width=100%>';
              
              
              json.objects.each(function(item) {
              // display each pending request replicating a normal web access query
              html += '<tr class="reportBodyRow"><td class="listBodyCell"><span class="reportBodyRowHtmlContainer">';
              
              html += '<div><table><tr>';
              html += '<td><b>' + item.attributes['RaiseUser'] + '</b> - ' + item.attributes['CreationDate'] + '<br>' + '<b>' + item.attributes['RaiseUser._ADCountry'] + '</b> - <b>' + item.attributes['RaiseUser._ADState'] + '</b>' + '<br>' + item.attributes['Description'] + '</td>';
              html += '<td><a href="" onclick="window.open(\'Chat.html?session=%22session%22:%22' + item.attributes['Guid'] + '%22,%22client%22:%22wa%22';
              html += '\',\'_blank\',\'toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=412,height=600\'); return false">';
              html += '<img src="../respond.png" height="40px" border=0 /></a></td>';
              html += '<td><img src="../logincident_dis.jpg" height="40px" border=0 /></td>';
              html += '<td><img src="../closechat_dis.jpg" height="40px" border=0 /></td>';
              html += '</tr>';
              //html += '<tr>';
              //html += '<td colspan="4"></td>';
              html += '</table></div>';
              
              
              html += '</span></td></tr>';
              });
              }
              else html = '<div class="contentHeader">' + NoPendingRequestsText + '</div>';
              $('PendingChatsDiv').innerHTML = html;
              }
              
              
              function GetActiveSessions_Response(response) {
              $('StatusDiv').hide();
              ResetError();
              var json = eval('(' + response.responseText + ')');
              var html = '';
              if (json.objects.length > 0) {
              html = '<table cellpadding=0 cellspacing=0 border=0 class="list" width=100%>';
              
              
              json.objects.each(function(item) {
              // display each pending request replicating a normal web access query
              html += '<tr class="reportBodyRow"><td class="listBodyCell"><span class="reportBodyRowHtmlContainer">';
              
              
              html += '<div><table><tr>';
              html += '<td><b>' + item.attributes['RaiseUser'] + '</b> - ' + item.attributes['CreationDate'] + '<br />' + item.attributes['Description'] + '</td>';
              html += '<td><a href="" onclick="window.open(\'Chat.html?session=%22session%22:%22' + item.attributes['Guid'] + '%22,%22client%22:%22wa%22,%22resume%22:%22resume%22';
              html += '\',\'_blank\',\'toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=412,height=600\'); return false">';
              html += '<img src="../respond.png" height="40px" border=0 /></a></td>';
              //html += '<td><img src="../logincident_dis.jpg" height="40px" border=0 /></td>';
              //html += '<td><img src="../closechat_dis.jpg" height="40px" border=0 /></td>';
              html += '</tr></table></div>';
              
              
              html += '</span></td></tr>';
              });
              }
              else html = '<div class="contentHeader">' + NoPendingRequestsText + '</div>';
              $('PendingChatsDiv').innerHTML = html;
              }
              
              
              function CheckSessions_Response(response) {
              ResetError();
              var json = eval('(' + response.responseText + ')');
              if (json.objects.length > 0) {
              SessionGuid = json.objects[0]['value'];
              LoadSession();
              }
              else ShowNewSessionPage();
              }
              
              
              function CheckSessions_ResponseBIT(response) {
              ResetError();
              var json = response.responseText.evalJSON();
              if (json.DataRows.length > 0) {
              SessionGuid = json.DataRows[0].Key;
              LoadSessionBIT();
              }
              else ShowNewSessionPageBIT();
              }
              
              
              function CheckSessions_ResponseBIT2(response) {
              ResetError();
              
              var json = ('{"DataRows":['+response.responseText+']}').evalJSON();
              
              if (json.DataRows.length > 0) {
              SessionGuid = json.DataRows[0].Key;
              LoadSessionBIT();
              }
              else ShowNewSessionPage();
              }
              
              
              function RespondSession_Response(response, successful) {
              // responded, now open it
              var url = WebAccess + '/Query/List.rails?class_name=' + ClassName + '&cns=Guid-e-0-&c0=' + SessionParameter;
              new Ajax.Request(url, {
              onSuccess: function(response) { CheckSessions_Response(response) },
              onFailure: function(response) { Ajax_Failed(ErrorRespondingToSession, response) }
              });
              }
              
              
              function RespondSession_ResponseBIT(response, successful) {
              // responded, now open it
              //var url = WebAccess + '/Query/List.rails?class_name=' + ClassName + '&cns=Guid-e-0-&c0=' + SessionParameter;
              var formVals = {
              "class_name" : ClassName,
              "key" : SessionParameter
              };
              
              
              new Ajax.Request(BridgeIT + '/api/form?class_name=' + ClassName + '&key=' + SessionParameter, 
              {
              
              method: 'get',
              parameters: Object.toJSON(formVals),
              //parameters: Object.toJSON(formVals),
              onSuccess: function(response2) { CheckSessions_ResponseBIT2(response2); },
              onFailure: function(response2) { Ajax_Failed(ErrorRespondingToSession, response2); }
              });
              
              }
              
              
              function ShowNewSessionPage() {
              $('StatusSpan').innerHTML = NewChatText;
              $('ChatSessionDiv').hide();
              $('ChatSessionDivBIT').hide();
              $('NewChatDiv').show();
              $('NewChatQuestion').value = '';
              $('NewChatQuestion').focus();
              clearInterval(GetCommentsTimer);
              }
              
              
              function ShowNewSessionPageBIT() {
              $('StatusSpan').innerHTML = NewChatText;
              $('ChatSessionDiv').hide();
              $('ChatSessionDivBIT').hide();
              $('NewChatDivBIT').show();
              $('NewChatQuestionBIT').value = '';
              $('NewChatQuestionBIT').focus();
              clearInterval(GetCommentsTimer);
              }
              
              
              // start new chat session
              function StartChatSession() {
              if ($('NewChatQuestion').value == '') return;
              $('NewChatSubmitButton').disabled = true;
              new Ajax.Request(WebAccess + '/object/save.rails', {
              method: 'post',
              parameters: 'class_name=' + ClassName + '&lifecycle_name=' + ChatProcess + '&is_new=true&Title=' + SessionTitle + '&Description=' + $('NewChatQuestion').value,
              onSuccess: function(response) { StartChat_Response(response) },
              onFailure: function(response) { Ajax_Failed(ErrorStartingSession, response) }
              });
              }
              
              
              // start new chat session
              function StartChatSessionBIT() {
              if ($('NewChatQuestionBIT').value == '') return;
              $('NewChatSubmitButtonBIT').disabled = true;
              
              var formVals = {
              "formValues": [
              {name:'Title', value: SessionTitle}, 
              {name:'Description', value:$('NewChatQuestionBIT').value}
              ],
              "class_name" : ClassName,
              "lifecycle_name" : ChatProcess
              };
              
              
              //var params = 'class_name=' + CommentClassName + '&formValues='+Object.toJSON(formVals)+'&lifecycle_name=' + ChatProcess;
              
                $('ChatCommentBIT').value = '';
              $('ChatCommentBIT').focus();
              
              
              new Ajax.Request(BridgeIT + '/api/form?class_name=' + ClassName + '&lifecycle_name=' + ChatProcess, 
              {
              method: 'post',
              parameters: Object.toJSON(formVals),
              onSuccess: function(response) { StartChat_ResponseBIT(response); },
              onFailure: function(response) { Ajax_Failed(ErrorStartingSession, response); }
              });
              }
              
              
              function StartChat_Response(response) {
              ResetError();
              var json = eval('(' + response.responseText + ')');
              SessionGuid = json['value'];
              LoadSession();
              }
              
              
              function StartChat_ResponseBIT(response) {
              ResetError();
              var json = response.responseJSON;
              SessionGuid = json['Key'];
              LoadSessionBIT();
              }
              
              
              // load existing session
              function LoadSession() {
              $('ChatHistory').innerHTML = '<br />';
              
              
              $('NewChatDiv').hide();
              $('NewChatDivBIT').hide();
              $('ChatComment').value = '';
              $('ChatEndedDiv').hide();
              $('ChatEndedDivBIT').hide();
              $('ChatCommentDiv').show();
              $('ChatSessionDiv').show();
              $('ChatComment').focus();
              $('NewChatSubmitButton').disabled = false;
              
              
              GetComments();
              GetCommentsTimer = setInterval('GetComments()', GetCommentsInterval);
              }
              
              
              function LoadSessionBIT() {
              $('ChatHistoryBIT').innerHTML = '<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />';
              
              
              $('NewChatDiv').hide();
              $('NewChatDivBIT').hide();
              $('ChatCommentBIT').value = '';
              $('ChatEndedDiv').hide();
              $('ChatEndedDivBIT').hide();
              $('ChatCommentDivBIT').show();
              $('ChatSessionDivBIT').show();
              $('ChatCommentBIT').focus();
              $('NewChatSubmitButtonBIT').disabled = false;
              
              
              GetCommentsBIT();
              GetCommentsTimer = setInterval('GetCommentsBIT()', GetCommentsInterval);
              }
              
              
              
              
              // get new comments
              function GetComments() {
              var url = WebAccess + '/Query/List.rails?class_name=' + CommentClassName + '&attributes=Id%2C' + CommentTextAttribute + '%2C_CreateDate%2C_CreateUser%2c' + CommentToParentRelationship + '.Status.Name%2C' + CommentToParentRelationship + '.RaiseUser.Title%2C' + CommentToParentRelationship + '.CurrentAssignment.User.Title&cns=' + CommentToParentRelationship + '-e-0-_a_Id-gte-1-';;
              url += '&c0=' + SessionGuid + '&c1=' + LastCommentID;
              new Ajax.Request(url, {
              onSuccess: function(response) { GetComments_Response(response) },
              onFailure: function(response) { Ajax_Failed(ErrorGettingComments, response) }
              });
              }
              
              
              function GetCommentsBIT() {
              var url = BridgeIT + '/api/query?class_name=' + CommentClassName + '&attributes=' + CommentIdAttribute + '%2C' + CommentTextAttribute + '%2C_CreateDate%2C_CreateUser%2c' + CommentToParentRelationship + '.Status.Name%2C' + CommentToParentRelationship + '.RaiseUser.Title%2C' + CommentToParentRelationship + '.CurrentAssignment.User.Title&cns=' + CommentToParentRelationship + '-e-0-_a_' + CommentIdAttribute + '-gte-1-';;
              url += '&c0=' + SessionGuid + '&c1=' + LastCommentID;
              new Ajax.Request(url, {
              method:'get',
              onSuccess: function(response) { console.log(response);GetComments_ResponseBIT(response); },
              onFailure: function(response) { Ajax_Failed(ErrorGettingComments, response) }
              });
              }
              
              
              function GetComments_Response(response) {
              ResetError();
              var NewComments = new Array();
              var NewCommentsText = '';
              var SessionEnded = false;
              
              
              var json = eval('(' + response.responseText + ')');
              if (json.objects.length > 0) {
              json.objects.each(function(item) {
              if (item.attributes['Id'] > LastCommentID) NewComments.push(item);
              });
              
              
              NewComments.sort(function(a, b) { return a.attributes['Id'] - b.attributes['Id'] });
              
              
              for (var i = 0; i < NewComments.length; i++) {
              NewCommentsText += '<br /><b>' + NewComments[i].attributes['_CreateUser'] + ' - ' + NewComments[i].attributes['_CreateDate'];
              NewCommentsText += '</b><br />' + NewComments[i].attributes[CommentTextAttribute];
              LastCommentID = NewComments[i].attributes['Id'];
              if (NewComments[i].attributes[CommentToParentRelationship + '.Status.Name'] == WaitingResponseStatus) $('StatusSpan').innerHTML = ChatPendingText;
              else if (NewComments[i].attributes[CommentToParentRelationship + '.Status.Name'] == InProgressStatus) {
              if (IsAnalystSession)
              {
              $('StatusSpan').innerHTML = ActiveAnalystSessionText.replace('{user}', NewComments[i].attributes[CommentToParentRelationship + '.RaiseUser.Title']);
              }
              else {
              $('StatusSpan').innerHTML = ActiveUserSessionText.replace('{analyst}', NewComments[i].attributes[CommentToParentRelationship + '.CurrentAssignment.User.Title']);
              }
              }
              else {
              $('StatusSpan').innerHTML = SessionEndedText;
              SessionEnded = true;
              }
              }
              
              
              if (NewCommentsText != '') {
              $('ChatHistory').innerHTML += NewCommentsText;
              //alert('about to scroll');
              $('ChatHistory').scrollTop = $('ChatHistory').scrollHeight + 200;
              //alert('scrolled');
              }
              
              if (SessionEnded == true) SessionEndedDisplay();
              }
              }
              
              
              function GetComments_ResponseBIT(response) {
              ResetError();
              var NewComments = new Array();
              var NewCommentsText = '';
              var SessionEnded = false;
              
              var json = response.responseText.evalJSON();
              if (json.DataRows.length > 0) {
              json.DataRows.each(function(item) {
              if (item.Values[CommentIdAttribute] > LastCommentID) NewComments.push(item);
              });
              
              
              NewComments.sort(function(a, b) { return a.Values[CommentIdAttribute]- b.Values[CommentIdAttribute] });
              
              
              for (var i = 0; i < NewComments.length; i++) {
              NewCommentsText += '<br /><b>' + NewComments[i].Values._CreateUser + ' - ' + NewComments[i].Values._CreateDate;
              NewCommentsText += '</b><br />' + NewComments[i].Values[CommentTextAttribute];
              LastCommentID = NewComments[i].Values[CommentIdAttribute];
              if (NewComments[i].Values[CommentToParentRelationship].Status.Name == WaitingResponseStatus) $('StatusSpan').innerHTML = ChatPendingText;
              else if (NewComments[i].Values[CommentToParentRelationship].Status.Name == InProgressStatus) {
              if (IsAnalystSession)
              {
              $('StatusSpan').innerHTML = ActiveAnalystSessionText.replace('{user}', NewComments[i].Values[CommentToParentRelationship].RaiseUser.Title);
              }
              else {
              $('StatusSpan').innerHTML = ActiveUserSessionText.replace('{analyst}', NewComments[i].Values[CommentToParentRelationship].CurrentAssignment.User.Title);
              }
              }
              else {
              $('StatusSpan').innerHTML = SessionEndedText;
              SessionEnded = true;
              }
              }
              
              
              if (NewCommentsText != '') {
              $('ChatHistoryBIT').innerHTML += NewCommentsText;
              $('ChatHistoryBIT').scrollTop($('ChatHistoryBIT').scrollHeight + 200);
              //$('html,body').animate({scrollTop: $(document).height()-$(window).height()},1400,"easeOutQuint");
              }
              
              if (SessionEnded == true) SessionEndedDisplayBIT();
              }
              }
              
              
              // send comment
              function SendComment() {
              if ($('ChatComment').value == '') return;
              var params = 'class_name=' + CommentClassName + '&is_new=true&' + CommentTextAttribute + '=' + $('ChatComment').value;
              params += '&parent_class_name=' + ClassName + '&parent_key=' + SessionGuid + '&parent_function_name=' + AddCommentAction;
                $('ChatComment').value = '';
              $('ChatComment').focus();
              
              
              new Ajax.Request(WebAccess + '/object/save.rails', {
              method: 'post',
              parameters: params,
              onSuccess: function(response) { SendComment_Response(response) },
              onFailure: function(response) { Ajax_Failed(ErrorSendingComment, response) }
              });
              }
              
              
              // send comment
              function SendCommentBIT() {
              if ($('ChatCommentBIT').value == '') return;
              var formVals = {
              "class_name" : CommentClassName,
              "formValues":[
              {name:'_Comment1', value:$('ChatCommentBIT').value}
              ]
              
              }
              
              
              var params = 'class_name=' + CommentClassName + '&formValues='+ Object.toJSON(formVals);
              
                $('ChatCommentBIT').value = '';
              $('ChatCommentBIT').focus();
              
              new Ajax.Request(BridgeIT + '/api/form?parent_class_name=' + ClassName + '&parent_key=' + SessionGuid + '&parent_function_name=' + AddCommentAction + '&class_name=' + CommentClassName, 
              {
              method: 'post',
              parameters: Object.toJSON(formVals),
              onSuccess: function(response) { SendComment_ResponseBIT(response) },
              onFailure: function(response) { Ajax_Failed(ErrorSendingComment, response) }
              });
              
              
              }
              
              
              function SendComment_Response(response) {
              ResetError();
              GetComments();
              }
              
              
              function SendComment_ResponseBIT(response) {
              ResetError();
              GetCommentsBIT();
              }
              // end of session
              function EndSession() {
              $('SendCommentButton').disabled = true;
              $('EndChatButton').disabled = true;
              new Ajax.Request(WebAccess + '/object/invokeFunction.rails?class_name=' + ClassName + '&function_name=' + EndChatAction + '&key=' + SessionGuid,
              {
              onSuccess: function(response) { EndSession_Response(response) },
              onFailure: function(response) { Ajax_Failed(ErrorEndingSession, response) }
              });
              }
              
              
              function EndSessionBIT() {
              $('SendCommentButtonBIT').disabled = true;
              $('EndChatButtonBIT').disabled = true;
              
              
              clearInterval(GetCommentsTimer);
              
              new Ajax.Request(BridgeIT + '/api/object?class_name=' + ClassName + '&function_name=' + EndChatAction + '&key=' + SessionGuid,
              {
              method: 'post',
              onSuccess: function(response) { EndSession_ResponseBIT(response) },
              onFailure: function(response) { EndSession_ResponseBIT(response) }
              });
              }
              
              
              function EndSession_Response(response) {
              ResetError();
              SessionEnded();
              }
              
              
              function EndSession_ResponseBIT(response) {
              ResetError();
              SessionEndedBIT();
              }
              
              
              function SessionEnded() {
              GetComments();
              SessionEndedDisplay();
              }
              
              
              function SessionEndedBIT() {
              
              
              GetCommentsBIT();
              SessionEndedDisplayBIT();
              }
              
              
              function SessionEndedDisplay() {
              clearInterval(GetCommentsTimer);
              $('ChatCommentDiv').hide();
              if (IsAnalystSession == false) $('EndUserSessionEndText').show();
              $('ChatEndedDiv').show();
              $('SendCommentButton').disabled = false;
              $('EndChatButton').disabled = false;
              SessionGuid = null;
              }
              
              
              function SessionEndedDisplayBIT() {
              clearInterval(GetCommentsTimer);
              $('ChatCommentDivBIT').hide();
              if (IsAnalystSession == false) $('EndUserSessionEndTextBIT').show();
              $('ChatEndedDivBIT').show();
              $('SendCommentButtonBIT').disabled = false;
              $('EndChatButtonBIT').disabled = false;
              SessionGuid = null;
              }
              
              
              // misc functions
              function GetParameter(Parameter) {
              Parameter = Parameter.toLowerCase();
              var ParaSplit = location.search.substring(1).split('&');
              
              
              for (var i = 0; i < ParaSplit.length; i++) {
              var KeyValue = ParaSplit[i].split('=');
              if (KeyValue[0].toLowerCase() == Parameter) return KeyValue[1];
              }
              return null;
              }
              
              
              function Ajax_Failed(ErrorMessage, response) {
              var ErrorText = ErrorMessage + ': ' + response.statusText + ' (' + response.status + ')';
              if (response.status == '403') ErrorText = ErrorNotLoggedIn;
              else $('ErrorSpan').innerHTML = ErrorText;
              $('StatusSpan').hide();
              $('ErrorSpan').show();
              }
              
              
              function ResetError() {
              $('ErrorSpan').hide();
              $('StatusSpan').show();
              }
              
              
              SessionGuid = null;
              window.onbeforeunload = ConfirmUnload;
              function ConfirmUnload() {
              if (SessionGuid != null) return ExitWarningText;
              }
              

               

              Motaz Alqaissi

              Tjdeed Technology

              • 6. Re: Chat and Social not working
                John Haddad Expert

                i replace this JS file .

                 

                 

                but still gives me an error :

                Error while checking for new chat comments: Internal Server Error (500)

                 

                i can't see the chat history

                • 7. Re: Chat and Social not working
                  John Haddad Expert

                  >

                  <Message

                  >

                  An error has occurred.

                  </Message

                  >

                  <ExceptionMessage

                  >

                  AttributeType Id not found.

                   

                  </ExceptionMessage

                  >

                  <ExceptionType

                  >

                  Touchpaper.Framework.Common.TouchpaperException

                  </ExceptionType

                  >

                  • 8. Re: Chat and Social not working
                    MotazAlqaissi ITSMMVPGroup

                    Dear John,

                     

                    You may need to change the values in the below lines:

                     

                    Motaz Alqaissi

                    TjDeeD Technology

                    • 9. Re: Chat and Social not working
                      John Haddad Expert

                      i've changed them to match what i have:

                       

                      // Site Constants 

                      BridgeIT = '/Workspace' 

                      WebAccess = '/ServiceDesk.Webacceess' 

                      • 10. Re: Chat and Social not working
                        MotazAlqaissi ITSMMVPGroup

                        Shared the updated module with you via email.

                         

                        Motaz Alqaissi

                        TjDeeD Technology

                        • 11. Re: Chat and Social not working
                          John Haddad Expert

                          Dear Motaz

                           

                          Thank you so much for helping