I need to convert this code to a snippet.......

  • 1
  • Question
  • Updated 2 years ago
  • Answered
Might anyone out there be able to help me convert this code to run as a JS snippet from a button in Skuid? I believe the only parameter to pass in is:

 id={!Contact.Id}

To do it as a snippet, I must have to reverence a model correct? Any direction would be helpful as I apparently slept through JavaScript class. 

THANKS!

______________________________________________________________________

<!--
{!REQUIRESCRIPT('/resource/smagicinteract__smJQuery/js/jquery-1.10.2.js')}
{!REQUIRESCRIPT('/resource/smagicinteract__smJQuery/js/jquery-ui-1.10.4.custom.min.js')} 


var cssUrlVal = '{!URLFOR('/resource/smagicinteract__smJQuery/css/sm-theme/jquery-ui-1.10.4.custom.min.css')}'; 

var fileref = document.createElement('link'); 
fileref.setAttribute('rel', 'stylesheet'); 
fileref.setAttribute('type', 'text/css'); 
fileref.setAttribute('href', cssUrlVal); 
document.getElementsByTagName('head')[0].appendChild(fileref); 

var url = "https://ashwani16-dev-ed--c.ap2.visual.force.com/apex/convCon?id={!Contact.Id}"; 
var j$ = jQuery.noConflict(); 
var modalDialog = j$('<div id="sendSMSPopup"></div>'); 
var md = modalDialog.html('<iframe id="iframeContentId" src="'+url+'" frameborder="0" height="100%" width="100%" marginheight="0" marginwidth="0" scrolling="yes" />'); 

md.dialog({ 
autoOpen: false, 
resizable: true, 
autoResize: true, 
width: 750, 
height: 600, 
modal: true, 
title: "Conversation View", 
draggable: true, 
close : function(event, ui){ 
window.top.location.reload(); 
} 
}); 
md.dialog("option", "title", "Conversation View").dialog('open'); 

var closeFun = function(event) {	
if(event.data === "close sendsms popup"){ 
// event.origin contains the host of the sending window. 
md.dialog('close'); 
} 
} 

if(!window.addEventListener){ 
window.attachEvent("onmessage", closeFun); 
} else{ 
var browserName = navigator.appName; 
if(browserName == 'Netscape'){ 
window.addEventListener("message", closeFun, false); 
}else{ 
window.addEventListener("message", closeFun); 
} 
}

-->
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb

Posted 2 years ago

  • 1
Photo of Bill McCullough

Bill McCullough, Champion

  • 12,436 Points 10k badge 2x thumb
Raymond,

Do you need a snippet for this?  It looks like this code just opens a pop up and displays the VisualForce page in an iFrame.  Couldn't you make a button that opens a pop up and displays the VisualForce page in a Template component (i.e. iFrame)?

Thanks,

Bill
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
ha! that is much easier. It SHOULD work. The VisualForce is displaying as blank. I merged in a Contact Id, but it is rendering with only some basic formatting and no data... I will keep working on it. Thanks for the suggestion!
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
This worked, Bill. Thanks! Gold Star for you!