+ Start a Discussion

s-control problem

I'm not a developer and I know I am treading in deep waters with javascript in s-controls.  I am trying to print out an order summary.  I can print out all the basic fields from the opportunity but I am trying to also list the lineitems on the opportunity on the same html page. 
I hunted for as much similar code on the app exchange and hacked this together.  If anyone could help me I would really appreciate it.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<link href="/dCSS/Theme2/default/common.css" type="text/css" rel="stylesheet" >
<script src="http://www.salesforce.com/services/lib/ajax/beta1/sforceclient.js"

<script language="javascript">

function initPage() {

sforceClient.init("{!API_Session_ID}", "{!API_Partner_Server_URL_60}");
window.setTimeout(";", 1000);

This is a function to retrieve the line items from the opportunity record. */
function getLineItems() {
//Querying salesforce for the Line Items associated to the given opportunity.
qr = sforceClient.Query("Select Id, Quantity, SalePrice, PricebookEntryId From OpportunityLineItem Where OpportunityId='{!Opportunity_ID}'");


//Get the data records from the QueryResult.
oliArray = qr.records;

function drawtable(){
<tr> <td> Select ID </td>
<td> Quantity </td>
<td> Sale Price </td>
<td> PricebookEntryID </td>
for (i=0;i<oliarray.length;i++){
for (j=0;j<oliarray[i].length;j++){



<body onload="PageInit();">
There are a lot of problems with this.

Starting with the onload function calling PageInit instead of initPage, using the old Beta, using the old service, etc.  I'll be happy to have a quick talk with you to go over some things if you would like to contact me.


i like to do exactly the same with you, and i'm recently headache with this because i'm not familiar with java & html programming language. After i had read your code. i find out something wired for me - API. Am i need any extra tools to create such s-control like what you doing? My company only purchase the basic tools, and with Professional Edition only. Can i create the s-control to print My-Order with only typing the HTML & Java in the s-control HTML field?

Yes you can just type the code in the HTML edit field. We are on enterprise.  I cannot remeber if scontrol is an option in PE.

 I used an HTML editor to get the table built and then copied and pasted the HTML- but that isn't a requirement, just a  sanity saver.  You can get the order printed using mail merge which works well for the basic relationships (all the fields on the opportunity, the line items and some primary contact and account data etc.)  I have recently had problems with this but I think it has to do more with my install becasue it has worked in the past.   

My reason for going s-control is becasue I need to reach over two objects through a custom object to retrieve some very specific data. The only way to do that is to go though an scontrol with some nested conditional queries.  FYI - My standard table with the opportunity data works fine.  The javascript does not. 

Professional Edition allows you to build simple s-Controls, but unless you've purchased an upgrade to get the API, you can't use the API in the s-Controls to do queries and updates.  :smileysad: