• Yaron Meiner
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies

I am sometimes amazed how a seemingly simple thing is some times made unneccessary difficult. Say you want to start a Live Agent session and have an input field to type an email address in right away without bothering the user with a pre-chat form. Should be as simple as the following code, right?: 

 

<html>
    <head>
	<!-- THIS NEEDS TO BE INCLUDED FOR EVERYTHING TO WORK -->
	<script type='text/javascript' src='https://c.la1c1.salesforceliveagent.com/content/g/deployment.js'></script>
	<script type='text/javascript'>
	liveagent.init('https://d.la1c1.salesforceliveagent.com/chat', '572D0000000011K', '00DD0000000oGsq');
	</script>
	<!-- END INCLUDE -->
    </head>
    <body>
	<!-- THIS IS JUST THE HEADER OF THE PAGE -->
	<h1>Chat med en kundebehandler!</h1>
	
	<!-- HERES THE BUTTON CODE FROM SF. ADD CONTENT WHERE THE COMMENT IS -->
	<div id="liveagent_button_online_573D0000000016a" style="display: none;" >
	    <input type="text" name="email" id="chatter_email" onBlur="emailUpdate()"/><br/>
	    <a href="javascript&colon;//Chat" onclick="liveagent.startChat('573D0000000016a')">Fyll inn din e-post og trykk her for å chatte</a>
	</div>
	<div id="liveagent_button_offline_573D0000000016a" style="display: none;">Kundebehandler offline</div>
	<script type="text/javascript">
	    if (!window._laq) { window._laq = []; }
	    window._laq.push(function()
		{liveagent.showWhenOnline('573D0000000016a', document.getElementById('liveagent_button_online_573D0000000016a'));
		liveagent.showWhenOffline('573D0000000016a', document.getElementById('liveagent_button_offline_573D0000000016a'));
	    });
	    function emailUpdate() {
		liveagent.addCustomDetail('Contact E-Mail', document.getElementById('chatter_email').value).map('Contact', 'Email', true, true, false);
		
	    }
	</script>
	<!-- END OF BUTTON CODE -->
    </body>
</html>

 But no - you get a javascript exception: "you cannot add a detail after page initialization".

 

In practice this means that you can add whatever you like before you load the page, but if you want the user to input something - you're ... toast (that was not the word I wanted to use, so I leave that up to your imagination). 

 

Stuff like that irritates me like a red hot poker up the butt.

 

Thanks for listening :) ...