Suggested answer
Like'; var react_Snippet = ' Like'; function HandleReactionRecord(e, targetRecordId) { var reaction_ControlId = "#"+e.id; try{ if(false == false){ window.location.href = "/signin?returnUrl="+window.location.pathname+window.location.search; }else{ $(reaction_ControlId).parent().block({ message: '', overlayCSS: { backgroundColor: '#e0dede', opacity:0.6} }); var entityParams = { isReactedByUser: $(reaction_ControlId).attr("user-reaction") == "true" ? true : false, reactionEntityName: $(reaction_ControlId).attr("reactionEntityName"), contactId: userId, recordId: targetRecordId, reactionType: "Like", reactionId: $(reaction_ControlId).attr("reaction-id"), siteId: "44c1922b-d231-4183-bae6-be148059122f", comment:$(reaction_ControlId).attr("commentflag") == 'true'?true:false }; LoadReactionControl(entityParams, successCallback, errorCallback); function successCallback(createdRecordId, res, status, xhr){ $(reaction_ControlId).attr("reaction-id", createdRecordId); if(createdRecordId != "" && createdRecordId != undefined){ $(reaction_ControlId).attr("user-reaction", true); $(reaction_ControlId).empty(); $(reaction_ControlId).html(reacted_Snippet); }else{ $(reaction_ControlId).attr("user-reaction", false); $(reaction_ControlId).empty(); $(reaction_ControlId).html(react_Snippet); } $(reaction_ControlId).parent().unblock(); } function errorCallback(res){ if(res.status == 500 && $(reaction_ControlId).attr("user-reaction") == "true"){ getRecord("mspwrplt_cmty_discussionreaction", '', targetRecordId, function(){}, errRetrieve); } $(reaction_ControlId).parent().unblock(); } function errRetrieve(res){ if(res.status == 404){ $(reaction_ControlId).attr("user-reaction", false); $(reaction_ControlId).attr("reaction-id", ''); $(reaction_ControlId).empty(); $(reaction_ControlId).html(react_Snippet); } $(reaction_ControlId).parent().unblock(); } } }catch(err) { console.error(err.message); $(reaction_ControlId).parent().unblock(); } }(1)