You need to sign in to do that
Don't have an account?
RK
Displaying Query Results in In-Line SControl...
Hey all,
I've seen examples where some query results could be displayed in an Inline-SControl on a page.
For example, I could have a custom object called "Business Plan". Within the Custom Object, there could be a section that calls an SControl that goes out, grabs the first name, last name, phone number and total sales for all producers that have a custom field of "Tier" flagged as an "A". The contents of this section would change as the people who are tagged as A's change.
I thought that there was something in the DreamForce 06 presentations (SControls for Dummies, for example), but I couldn't find anything. Also, I seem to recall that there was an SF.com app out on the AppExchange that essentially did this, but I couldn't find it, either (The Mass Update Opportuntiies in some ways does it, but it is much more complex that my needs)..I thought that it was a mass view of contacts, but I might be wrong. And I recall the foundation being the use of the SF.com Style Sheets.
Wondering if anyone has the same recollection as me. As I have done many times in the past (with all of your help), I plan on re-engineering the existing code to fit the specific needs of my users.
Thanks much for any insight...
RK
P.S. If you are like me and you don't have the knowledge to do coding on your own and you rely on reverse engineering other people's code, please vote on my Idea below. Thanks!
http://ideas.salesforce.com/article/show/57416/A_UserSubmitted_CodeSControlEnhancement_Sample_Library
I've seen examples where some query results could be displayed in an Inline-SControl on a page.
For example, I could have a custom object called "Business Plan". Within the Custom Object, there could be a section that calls an SControl that goes out, grabs the first name, last name, phone number and total sales for all producers that have a custom field of "Tier" flagged as an "A". The contents of this section would change as the people who are tagged as A's change.
I thought that there was something in the DreamForce 06 presentations (SControls for Dummies, for example), but I couldn't find anything. Also, I seem to recall that there was an SF.com app out on the AppExchange that essentially did this, but I couldn't find it, either (The Mass Update Opportuntiies in some ways does it, but it is much more complex that my needs)..I thought that it was a mass view of contacts, but I might be wrong. And I recall the foundation being the use of the SF.com Style Sheets.
Wondering if anyone has the same recollection as me. As I have done many times in the past (with all of your help), I plan on re-engineering the existing code to fit the specific needs of my users.
Thanks much for any insight...
RK
P.S. If you are like me and you don't have the knowledge to do coding on your own and you rely on reverse engineering other people's code, please vote on my Idea below. Thanks!
http://ideas.salesforce.com/article/show/57416/A_UserSubmitted_CodeSControlEnhancement_Sample_Library
Message Edited by RK on 04-19-2007 08:26 AM
I went and modified (some might say bastardized :smileyvery-happy:) the code, and have at least been able to
get the resultant data to output to the screen. For the life of me, I can't get the style sheet to apply. Code is below. Any input would be happily and gratefully received.
Humbly,
RK
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<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">
<html>
<head>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
<title></title>
<!-- Next is a simple stylesheet for results display - also uses the standard SFDC css, see link refs above-->
<style type="text/css">
TH {background-color: yellow; color: white}
TD.markerFont {background-color: yellow; color: white}
span.GRMsummaryTxt {font-weight: bold}
</style>
<script src="/soap/ajax/9.0/connection.js"></script>
<script>
var externalWholesalerId = '{!$User.Id}';
function createTable(){
//below is the relatively simple query to determine which contacts should be displayed
var queryContact = sforce.connection.query("Select Id, X2007_Resultant_Sales_Goal__c, X2007_Resultant_Sales__c, OwnerId, Full_Name__c from Contact where X2006_Rank_Within_Region__c > 0 and X2006_Rank_Within_Region__c < 51 and Known_Terminated__c = FALSE and OwnerID = '"+externalWholesalerId+ "' " );
var contactRecordsLength = queryContact.getArray("records");
var totalcontactsToBeAdded = contactRecordsLength.length;
contactsToBedisplayed = queryContact.getArray("records");
var contactsToBedisplayedArray= new Array();
var recordsContact = queryContact.getArray('records');
for (var i = 0; i < recordsContact.length; i++)
{ //
alert ("in if loop");
alert("i equals " + i);
if (i==0) { //creates header row for table
htmlstr="<DIV><TABLE width=100% class=list border=0>";
htmlstr+="<tr class=headerRow height=20><TH>Name</TH><TH>Address</TH><TH>Result</TH><TH>Returned</TH><TH>Coords (Lat,Lng)</TH><TH>Accuracy</TH></TR>";
}
taskCreatedLineItem = contactsToBedisplayed[i];
var conId = taskCreatedLineItem .get("Id");
var resultantSales = taskCreatedLineItem .get("X2007_Resultant_Sales__c");
var resultantSalesGoal = taskCreatedLineItem .get("X2007_Resultant_Sales_Goal__c");
var fullName = taskCreatedLineItem .get("Full_Name__c");
var ownerId = taskCreatedLineItem .get("OwnerId ");
alert ("Contact ID is " + conId);
//below appends contact data to table. Not yet complete, but works in concept.
htmlstr+="<TR><TD><A target='_blank' HREF='/"+conId+"'>"+fullName+"</TD><TD>"+resultantSales+"</TD><TD>Success</TD><TD>"+resultantSalesGoal+"</TD><TD>"+conId+"</TD><TD>"+conId+"</TD></TR>";
}
htmlstr+="</TABLE></DIV>";
//innerHTML=htmlstr;
alert ("Out of if statement. Resultant HTML code is:" + htmlstr);
document.write(htmlstr); //outputs to screen....would like to have this data formatted per stylesheet
}
</script>
</head>
<body onload="createTable();">
</body>
</html>
RK,
A great tutorial is available on ADN
you need to specify the body class and top level DIV to get the main look & feel. You may also need to apply content DIVs to your table.
Code excerpt for (account) example is below
(Please use SRC button to insert code in the community postings, or it is difficult to view your post, it askews formatting!)
Code:
Thanks so much for the link to that tutorial. It was exactly what I needed, and I was able to get my formatting as
I wanted it.
I have run into another issue, however - I am primarly returning contact data - name, phone number, mailing city,
etc. But, I am also looking to return the Account Name for the contact. My query code is listed below:
Code:
Further in the code, I extract the values for the individual fields, as shown here:
Code:
Everything generates correctly, with the exception of the Account Name or the Account ID (doesn't matter which I
choose to display) - they both come back with a NULL value.
From what I have read, I beleive that I might need to use QueryResultIterator? Does that seem logical?
I've run the query within AjaxTools, and I see that it use used in the "Generate Sample" code, but I'm not certain
if that is only needed because I'm pulling a field from the related Account.
Am I barking up the right tree?
Thanks,
RK
Try this:
HTHs,
For those of you who are code challened like me, the result is below. It might not be pretty, but it works.
Thanks to all...and should you have a desire for a sample code library for examples like this, please vote on my idea out on ideas.salesforce.com:
http://ideas.salesforce.com/article/show/57416/A_UserSubmitted_CodeSControlEnhancement_Sample_Library
Code: