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
NYCMeghanNYCMeghan 

S-Control Display Help

First off I preface by saying that I am not a developer, however with a shortage of developer talent at my firm I have taken on some projects a bit over my head.

 

I have created a custom object that is essentially a quota tracker.  As part of the ability to track monthly achievements, I want to include some information on monthly commission payout information.  I've got the custom fields to track monthly achievement metrics, where I am having trouble is with the display of monthly payout info (we pay our sales reps their commission when we receive the first half of a 2 invoice deal)

 

I have an S-Control that shows all closed/won opportunities for all reps in a given month (dates hardcoded).  When I change it to a specific userID it limits the results to that user - makes sense.  However, while the query works in apex explorer, it renders a blank section on the page layout.

 

The bigger issue is that I don't want to have to hardcode the userid into 12 separate s-controls and create 16 separate record types off of this object (16=number of salespeople).

 

Is it possible to generate the results off of a user ID related field?  The custom object (Quota Management) is related to both the opportunity and User via lookups.  I can't create a Master/Detail between it and opportunities as we already have several years worth of opportunities established.  Each Quota Management record can have multiple opportunities, so a Master/Detail off of the opportunity won't work either.

 

And yes, I realize that this can probably be very easily achieved using visualforce, but when I tried to create the standard controller and custom extension I nearly tore my hair out.   

 

And then there is the issue of why it is not displaying on the page layout.  I was getting errors, but now no errors - just blank. 

 

Much rambling, I know - but hopefully someone will take pity on me and see what the heck I have screwed up in this code and how I might be able to reference a UserId rather than have to hardcode one in:

 

<html> <head> <script src="/soap/ajax/10.0/connection.js"></script> <script src="/js/dojo/0.4.1/dojo.js"></script> <script type="text/javascript" src="/js/functions.js"></script> <link href="/dCSS/Theme2/default/common.css" type="text/css" media="handheld,print,projection,screen,tty,tv" rel="stylesheet" > <link href="/dCSS/Theme2/default/custom.css" type="text/css"media="handheld,print,projection,screen,tty,tv" rel="stylesheet"> <script> dojo.addOnLoad(init); function init() { var callback = { onSuccess : displayResult, onFailure : displayError }; sforce.connection.query("SELECT Id, OwnerId, Name, StageName, Amount, CloseDate, Type, Sale_Type__c, Payment_Status__c, Payment_Received__c, Commissioned_On__c, Commission_Percentage__c, Commission_Amount__c FROM Opportunity WHERE IsWon=TRUE AND CloseDate >=2009-04-01 AND CloseDate <2009-05-01 AND Payment_Status__c <> null AND OwnerId='00560000000ygeIAAQ' Order By CloseDate LIMIT 500, callback"); } function displayResult(result) { var it = new sforce.QueryResultIterator(result); var html = []; html.push("<table class='list'>"); html.push("<tr class='headerRow'> "); html.push("<th class='table detail'>Opportunity Owner</th>"); html.push("<th>Name</th>"); html.push("<th>Stage</th>"); html.push("<th>Amount</th>"); html.push("<th>Close Date</th>"); html.push("<th>Type</th>"); html.push("<th>Client Payment Status</th>"); html.push("<th>Commissioned On</th>"); html.push("<th>Sale Type</th>"); html.push("<th>Commission Percentage</th>"); html.push("<th>Commission Amount</th></tr>"); while(it.hasNext()) { var record = it.next(); html.push("<tr class='headerRow'><td> " + record.OwnerId + "</td>"); html.push("<td>" + record.Name + "</td>"); html.push("<td>" + record.StageName + "</td>"); html.push("<td>" + record.Amount + "</td>"); html.push("<td>" + record.CloseDate + "</td>"); html.push("<td>" + record.Type + "</td>"); html.push("<td>" + record.Payment_Status__c + "</td>"); html.push("<td>" + record.Commissioned_On__c + "</td>"); html.push("<td>" + record.Sale_Type__c + "</td>"); html.push("<td>" + record.Commission_Percentage__c + "</td>"); html.push("<td>" + record.Commission_Amount__c + "</td></tr>"); } html.push("</table>"); document.getElementById("output-div").innerHTML = html.join(""); } function displayError(error) { document.getElementById("output-div").innerHTML = "oops something went wrong ... " + error; } </script> </head> <body>

SControl Display Issue