function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
shan876shan876 

S-Control On Homepage????

I have the following S-Control code:
Code:
<html> 
<head> 
<meta http-equiv=“refresh” content=“600″ /> 
<script type="text/javascript" src="/soap/ajax/10.0/connection.js"></script> 
<script type="text/javascript"> 
window.onload=init_page; 
function init_page() 
{ 
var j= ""; 
var output=""; 
strSQL = "Select Id,AS400_Account_Number__c,Name,BillingCity,SF_DATE_ON_SERVICE__c from Account where OwnerId='{!$User.Id}' and SF_DATE_ON_SERVICE__c = LAST_N_DAYS:30 ORDER BY SF_DATE_ON_SERVICE__c"; 
var result = sforce.connection.query(strSQL); 
var records = result.getArray("records"); 
for (var i=0; i<records.length; i++) 
{ 
j +='<a href="/' + records[i].Id + ' "target=_blank"">' + (i+1) +') ' + records[i].AS400_Account_Number__c + ' - ' + records[i].Name + ' - ' + records[i].BillingCity + ' - ' + records[i].SF_DATE_ON_SERVICE__c + '</a><br>&nbsp;' 
} 
document.getElementById('div_tag').innerHTML = j ; 
} 
</script> 
</head> 
<body bgcolor="#EEEEEE"> 
<font size="2" face="Garamond"> 
<div id="div_tag">Loading...</div></font> 
</body> 
</html>

 How do I display this on the Homepage... This is a Custom S Control....
Greg HGreg H

You need to create a Home page component.  Make the component HTML and add an IFRAME tag which references your sControl.  You'll need to modify your sControl to resize the iframe after the data loads and that should keep the new iframe on the home page from negatively impacting your users.

Code:
<iframe id="sControlTarget" name="sControlTarget" src="/servlet/servlet.Integration?lid=000000000000000&ic=1" frameBorder="0" width="100%" height="100"></iframe>

-greg

shan876shan876
Thank You ... You are awesome it worked out for me...:smileyvery-happy:
gmc74gmc74

Hi Greg,

I was wondering if you could help me with something.

I am trying to do something very similar, but I am not sure how to do what you are referring to. 

I have an S-Control titled 'CaseTest' that I created using the Ajax Tools -

Code:
<html>
<!--
Generated by AJAX tools
Date : Thu Jan 17 2008 15:58:00 GMT-0700 (US Mountain Standard Time)
Template : listview.html by manoj@cheenath.com
SControl : CaseTestSControl
-->

<html>

<head><title>listview</title>

<link rel="shortcut icon" href="/favicon.ico"/>
<script src="/soap/ajax/8.0/connection.js"></script>
<script src="/js/dojo/0.3.1/dojo.js"></script>
<title>CaseTestSControl</title>

<style>
table {
font-family: Lucida Grande, Verdana;
font-size: 0.8em;
width: 100%;
border: 1px solid #ccc;
cursor: default;
}

* html div.tableContainer {
/* IE only hack */
width: 95%;
border: 1px solid #ccc;
height: 285px;
overflow-x: hidden;
overflow-y: auto;
}

table td,
table th {
border-right: 1px solid #999;
padding: 2px;
font-weight: normal;
}

table thead td, table thead th {
background: #94BEFF;
}

* html div.tableContainer table thead tr td,
* html div.tableContainer table thead tr th {
/* IE Only hacks */
position: relative;
top: expression( dojo.html.getFirstAncestorByTag(this, 'table').parentNode.scrollTop-2);
}

html>body tbody.scrollContent {
height: 262px;
overflow-x: hidden;
overflow-y: auto;
}

tbody.scrollContent td, tbody.scrollContent tr td {
background: #FFF;
padding: 2px;
}

tbody.scrollContent tr.alternateRow td {
background: #e3edfa;
padding: 2px;
}

tbody.scrollContent tr.selected td {
background: yellow;
padding: 2px;
}

tbody.scrollContent tr:hover td {
background: #a6c2e7;
padding: 2px;
}

tbody.scrollContent tr.selected:hover td {
background: #ff3;
padding: 2px;
}
</style>

<script type="text/javascript">
dojo.require("dojo.widget.SortableTable");
dojo.addOnLoad(displayTable);


function displayTable() {
var query = "Select " +
"Id,CaseNumber,Status,Remaining__c,Route_To_User__c,Route_To_Group__c" +
" from Case where Status = 'New' ORDER BY Remaining__c";

var result = sforce.connection.query(query);

var sb = new sforce.StringBuffer();
sb.append("<tr>");
sb.append("<td>No</td>");

sb.append("<td>Id</td>");

sb.append("<td>CaseNumber</td>");

sb.append("<td>Status</td>");

sb.append("<td>Remaining__c</td>");

sb.append("<td>Route_To_User__c</td>");

sb.append("<td>Route_To_Group__c</td>");

sb.append("</tr>");

while (true) {
if (result.size > 0) {
for (i = 0; i < result.records.length; i++) {
var record = result.records[i];
sb.append("<tr><td>").append(i).append("</td>");

sb.append("</td><td> ").append(editLink(record, "Id"));

sb.append("</td><td> ").append(editLink(record, "CaseNumber"));

sb.append("</td><td> ").append(editLink(record, "Status"));

sb.append("</td><td> ").append(editLink(record, "Remaining__c"));

sb.append("</td><td> ").append(editLink(record, "Route_To_User__c"));

sb.append("</td><td> ").append(editLink(record, "Route_To_Group__c"));

sb.append("</td></tr>");
}
}
if (result.done == "true") {
break;
} else {
result = sforce.connection.queryMore(result.queryLocator);
}
}
document.getElementById("list-view-table").innerHTML = sb.toString();
}


function editLink(record, field) {
var value = record[field];
value = value — value : "&nbsp;";
return value;

//todo: edit link
return "<a href='javascript: editCell(\"" + record.Id +
"\",\"" + field + "\",\"" + value + "\")'>" +
value + "</a>";
}


function editCell(id, field, value) {
var newVal = prompt("Enter new text", value);
if (newVal === null || newVal === value) {
alert("Field not changed");
return;
} else {
value = newVal;
}
var record = new sforce.SObject("Account");
record.Id = id;
record[field] = value;

try {
result = sforce.connection.update([record]);
if (result[0].getBoolean("success") == false) {
alert("update failed");
} else {
//initPage();
}
} catch (e) {
alert("update failed");
//sforce.debug.display(e);
}
}
</script>
</head>

<body>

<div class="tableContainer">

<table dojoType="SortableTable" id="list-view-table"
headClass="fixedHeader" tbodyClass="scrollContent"
enableMultipleSelect="true" enableAlternateRows="true"
rowAlternateClass="alternateRow" cellpadding="0" cellspacing="0" border="0">
</table>
</div>

</body>
</html>

but I am not sure what I put in the Home Page Component and what gets added to the S-Control. 

Also, I have a Look up field in here called Route_To_User__c, do you know how I can return the user name here instead of the ID?

Thanks for the help.

Grant
 

Greg HGreg H
The code you wrote in your last post will be in the sControl.  The code I wrote (with the iframe tag) earlier in this listing is what will be in the Home page component.
 
Since your lookup is only returning an Id you'll need to query or retrieve the corresponding name in your sControl.
 
Hope this helps,
-greg
shan876shan876

Hi Greg:

   The way I did it, was I placed on the homepage component the HTML iFrame linking to the S-control...

So in my S-control I would place the code that you have listed here and then call in through an iframe... I hope that helps... That is the only way I know how to do it unless visualforce comes out soon I hope and we can change the homepage on a fly with actual code u know...

Right now Im trying to do a print button when a person selects the cases they want from the queue, they could hit print and it prints all detail one by one...

the other is to override a close button on the case depending on case reason....

whooopppyyy funnnn... :smileytongue:

Anyway I hope that helps someway and hope you figure it out....Good Luck....

Thanks

gmc74gmc74

Is SOQL complex enough to allow nested queries?

I will give that a go, thanks a lot!

gmc74gmc74

I ran into a bit of a snag, my S-Control works in Firefox, but not in IE, any know why that is?

Unfortunately, we are pretty much a Microsoft shop, and everyone uses IE... I prefer firefox most of the time, but I have to appease the masses.

Edit - It is getting an Unkown Runtime Error on the call to the S-Control

Thanks



Message Edited by gmc74 on 01-18-2008 07:30 AM