• London Ben
  • NEWBIE
  • 25 Points
  • Member since 2008

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 29
    Replies

Hi all

 

I'm working on a project to migrate a website to 'sites'

 

One thing that has me stumped at the moment is implementing 'search' functionality.

 

By this, I don't mean searching of salesforce objects, but searching content of pages 'like google'

 

This seems like something that someone must have tackled before - I've attempted to include the googlesearch api, but this doesnt seem to want to play ball on the sites platform..

 

Included my attempt here just for reference... (please note that the included api key will only work with my registered site - so for any playing about you would need to register with google and substitute with your own api code)

 

Any ideas would be most welcome - cheers!

Ben

 

 

<apex:page >
<script src="http://www.google.com/jsapi?key=ABQIAAAAFhpfQ8ljjRgKr3ylBZopURSu2Q3V9tNIMC-TQb4qeACXjenZIBTnpLOVK_O-z--z6YIDdEekHLB4Jg" type="text/javascript"></script>
<script>
var previousOnload = window.onload;
window.onload = function() {
if (previousOnload) {
previousOnload();
alert('loading...');
// Create a search control
var searchControl = new google.search.SearchControl();
// Add in a full set of searchers
var localSearch = new google.search.LocalSearch();
searchControl.addSearcher(localSearch);
searchControl.addSearcher(new google.search.WebSearch());
// Set the Local Search center point
localSearch.setCenterPoint("New York, NY");
// Tell the searcher to draw itself and tell it where to attach
searchControl.draw(document.getElementById("searchcontrol"));
// Execute an inital search
searchControl.execute("Google"); }
google.setOnLoadCallback(function);
}
}
</script>
<div id="searchcontrol">Loading...</div>
</apex:page>

 

 

 

Message Edited by London Ben on 08-27-2009 10:14 AM
Hi guys,

I'm experiencing some unexpected behavior when trying to use the apex:repeat function to render tabs....

Basically it seems that tabs cannot be created on demand?  My controller is definitely returning data... as the second page block in my sample will show... repeat works - just the tabs are not rendered..

I'm sure any of you guys can see where I was going with this - and I guess I can achieve a similar result by dropping down to boring old html - just trying to use the standard components (as per best practice)

Any assistance greatly appreciated - as the purist coder me is seriously disturbed at the moment...

here is my 'simplified' and easily testable page & controller

Code: VF PAGE
<apex:page controller="clsRecordType">
    <apex:pageBlock >
        <apex:tabPanel id="theTabPanel">
            <apex:tab label="Account Types"/>
            <apex:repeat value="{!RecordTypes}" var="types">
                <apex:tab label="{!types.Name}"/>     
            </apex:repeat>
        </apex:tabPanel>
    </apex:pageBlock>

    <apex:pageBlock >
        <apex:repeat value="{!RecordTypes}" var="types">
            {!types.Name}<br/>       
        </apex:repeat>
    </apex:pageBlock>
</apex:page>

and the controller

Code:
public class clsRecordType {

    list<RecordType> lrecordtypes;

    public list<RecordType> getRecordTypes() {
        if(lrecordtypes==null) lrecordtypes = [Select Name, Id, Description From RecordType  where SobjectType = 'Account' and IsActive=True];
        return lrecordtypes;
        }
   }

 
 

argh!!!!

I'm so sick of seing unreadable blocks of code full of smileys!!!!

Would you folks looking for answers PLEASE do us all a favour and use the little 'SRC' button!!!!

grr!  (not that any of the muppets who make this mistake will ever read this)
Hello Guys & Gals,
 
I thought I'd throw this out to the community as something that others might find useful.
 
I've had to implement this a number of times now - as no doubt some of you have already seen - there is no related list to show the opportunity contact roles for a 'contact'
 
This S-Control provides pretty much the same functionality.
 
Any suggestions to improve this are welcome... let me know if you find this useful.
 
Ben :)
 
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  "http://www.w3.org/TR/html4/loose.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>
<script src="/soap/ajax/10.0/connection.js" type="text/javascript"></script>
<script type="text/javascript" src="/js/functions.js"></script>
<script>
function Init() {

   //////////////////////////////////////////////////////////////////////////////////////////////////
   //                                                
   //             Developed March 2008   
   //               by Ben Ingram                    
   //           beningram@hotmail.com              
   //  May be re-used or altered so long as the credit remains :)                                              
   //                                                
   //                                                
   //  This s-Control for salesforce.com provides  
   //  visibility of all oportunities for which a  
   //  contact is listed as an Opportunity Contact 
   //                                                
   //  To Implement this s-Control:
   //    1. Add a new s-Control of type HTML
   //    2. Insert this code (all) into the HTML Body of the new Control
   //    3. Name the control something appropriate such as 'Contact_Opportunity_Roles'
   //    4. Edit the appropriate page layout for 'Contacts'
   //    5. Create a 'new section' to contain this inline s-control
   //       I recommend immediately preceding the related list area
   //    6. Drag the s-control from the list on the right into your new section
   //    7. Set the properties of this s-control to set the height = 100
   //    8. Enjoy :)
   //    
   //////////////////////////////////////////////////////////////////////////////////////////////////

  try{

    // Query the SOQL to return the related OpportunityContact records, along with the parent Opportunity details as required
    var SearchString="Select Id, ContactId, Role, IsPrimary, OpportunityId, Opportunity.Name, Opportunity.StageName From OpportunityContactRole Where ContactId = '{!Contact.Id}' ";
    var queryResults = sforce.connection.query(SearchString);
    var queryRecords = queryResults.getArray('records');
    var txtOutput = ""

    if (queryRecords.length > 0){
 
      // Rows returned, so first setup the column headers (hard coded - potentially revise this)
      var txtOutput = "<table class='list' width='100%' border='0' cellspacing='0' cellpadding='0'>";
      txtOutput = txtOutput + "<tr class='headerRow' height=20>";
      txtOutput = txtOutput + "<th nowrap>Opportunity</th>";
      txtOutput = txtOutput + "<th nowrap>Stage</th>";
      txtOutput = txtOutput + "<th nowrap>Role</th>";
      txtOutput = txtOutput + "<th nowrap>Is Primary</th></tr>";

      // Next Loop through the result array (row by row)
      for (var i = 0; i < queryRecords.length; i++) {

        // queryRecord = the Current row within the array
        var queryRecord = queryRecords[i];

        // OppRecord = the sub array row containing the linked Opportunity details
        var OppRecord = queryRecord.get("Opportunity");

 // Now build the results output row by row 
        txtOutput = txtOutput + "<tr class='dataRow' onmouseover=hiOn(this) onmouseout=hiOff(this)>";
        txtOutput = txtOutput + "<td class='datacell'><a href='/"+ queryRecord.get("OpportunityId") +"' target=_parent>" + OppRecord.get("Name") + "</a></td>";
        txtOutput = txtOutput + "<td> "+ OppRecord.get("StageName") + "</td>";
        txtOutput = txtOutput + "<td> "+ queryRecord.get("Role") + "</td>";

 // Display the standard grid checkbox image (checked or unchecked as appropriate)
        if(queryRecord.get("IsPrimary")=="true"){
          txtOutput = txtOutput + "<td><img src='/img/checkbox_checked.gif' alt='Checked' width='21' height='16' class='checkImg' title='Checked' /></td></tr>";} else {
          txtOutput = txtOutput + "<td><img src='/img/checkbox_unchecked.gif' alt='Not Checked' width='21' height='16' class='checkImg' title='Not Checked' /></td></tr>";
        } // end if (queryRecord.get("IsPrimary")=="true")
      } //end of array loop

     // Get rid of ugly white box by filling the gap with empty space 
     if (queryRecords.length == 1){
 txtOutput = txtOutput + "</table>&nbsp;<br> &nbsp;<br> &nbsp;";
 }
     if (queryRecords.length == 2){
 txtOutput = txtOutput + "</table>&nbsp;<br> &nbsp;";
 }
     if (queryRecords.length > 2){
 txtOutput = txtOutput + "</table>"; 
 }
    } else { 
      // there were no rows returnd from the SOQL query - so build a message to inform the user that this contact is not related to any opportunities
      txtOutput=txtOutput + "<font face = 'Verdana' size = '2'>This Contact has no specified Opportunity Contact Roles</font><br> &nbsp;<br> &nbsp;<br> &nbsp;<br> &nbsp;<br> &nbsp;<br>";
    }
 
  // Substitute the div mainBody contents for the generated HTML content
  document.getElementById("mainBody").innerHTML = txtOutput;

  }
  catch (error)
    {
      alert(error.faultstring);
    }
 
  }

</script>
</head>

<body class='account' onload="Init();" >
  <div class="bPageBlock secondaryPalette" style="border-top:0px; border-bottom:0px; margin-bottom:0px; padding-bottom:0px">
    <div id="mainBody"  class=pbBody style="margin-right:0px">
    </div>
  </div>
</body>
</html>

 

Hi all

 

I'm working on a project to migrate a website to 'sites'

 

One thing that has me stumped at the moment is implementing 'search' functionality.

 

By this, I don't mean searching of salesforce objects, but searching content of pages 'like google'

 

This seems like something that someone must have tackled before - I've attempted to include the googlesearch api, but this doesnt seem to want to play ball on the sites platform..

 

Included my attempt here just for reference... (please note that the included api key will only work with my registered site - so for any playing about you would need to register with google and substitute with your own api code)

 

Any ideas would be most welcome - cheers!

Ben

 

 

<apex:page >
<script src="http://www.google.com/jsapi?key=ABQIAAAAFhpfQ8ljjRgKr3ylBZopURSu2Q3V9tNIMC-TQb4qeACXjenZIBTnpLOVK_O-z--z6YIDdEekHLB4Jg" type="text/javascript"></script>
<script>
var previousOnload = window.onload;
window.onload = function() {
if (previousOnload) {
previousOnload();
alert('loading...');
// Create a search control
var searchControl = new google.search.SearchControl();
// Add in a full set of searchers
var localSearch = new google.search.LocalSearch();
searchControl.addSearcher(localSearch);
searchControl.addSearcher(new google.search.WebSearch());
// Set the Local Search center point
localSearch.setCenterPoint("New York, NY");
// Tell the searcher to draw itself and tell it where to attach
searchControl.draw(document.getElementById("searchcontrol"));
// Execute an inital search
searchControl.execute("Google"); }
google.setOnLoadCallback(function);
}
}
</script>
<div id="searchcontrol">Loading...</div>
</apex:page>

 

 

 

Message Edited by London Ben on 08-27-2009 10:14 AM
I would like to replace the opportunity product selection page with something more user friendly instead of just displaying a flat list of products. The ideas is a tree control display like:
 
+ Models
   + Family
      + Product Line
 
Model is defined by product record type: Model, Accessory
Family is defined by product family, e.g. "select family from product2 where recordtype = :model"
Product Line is defined by a custom field on Product, e.g. "select productline__c from product2 where recordtype=:model and family=:family"
Clicking + at product line gives you the products, e.g, "select name, ... from product2 where recrodtype=model and family=:family and productline__c = productline__c"
 
So, initially + Models isdisplay. Clicking on + expands to the Families under model. Clicking on a Family expands to the Product Lines under that Family, clicking + on product lines list all product under that recordtype, family, product line.
 
All obviously are controled by the selected Price Book.
 
Question: the functionality from an UI point of view is similar to what we have in the standard application under Setup: Clicking + under Customization gives you a list of standard objects, clicking a + next to a standard object gives you the various tasks you may perform.
 
How to do this on an APEX page?

Best regards,
Per
Hi,
 
i am facing scenerio where i have to access page attributes from controller extension,
as

get and set 'showHeader' and 'sidebar' attribute of apex:page from Controller extension, means at runtime based on query string value.

Is it possible?

 

Any help would be highly appreciated,

Thanks in advance.

 

 

 

 
  • October 13, 2008
  • Like
  • 0
As a developer working side by side with a non-developer admin, I have a real need to be able to coordinate how new fields and validation rules will affect not only my Triggers and Classes, but also my test methods (a common oversight).

As it is - I have been keeping a matrix of our Objects, Custom Objects, Fields and Triggers on a spreassheet. Last night I suddenly thought - what if we could use VisualForce to let admins view our object relationships in a simpler away?

The data is all there, of course, the trick is making a tool that would be usable for my specific purpose. I don't need a change log or versioning system for my apex (that would be nice but overkill). I can see a need to have a usable way to browse SF objects & see what other things (objects, fields and APEX code) could be affected by changes to a given field/object.

I'm interested to see if anyone had thought of this?

Since the tool Im imaginig would by nature have to be able to deal with generic objects, it seems like something a group could contribute to and share the reward. Maybe it's too large of a task or not feisable based on the metadata exposed. If possible, I think the return would be worth it - especiialy for smaller companies like mine (who have limited staff but make lots of changes & additions as we slowly realize what SF can do for us).

Just curious.
* How to integrate FDC with a back-end MS SQL Server in real-time?

Anyone know why I have suddenly lost the ability to include a VF page in one of my sections on a custom object page layout?  It used to be there as recently as a few weeks ago and now I only see Scontrols, related lists, custom links, and fields for my object, no more "Pages".

Please advise...

Thanks
3 days old (new) to salesforce!
i need to invoke a webservice from a tab like contacts when a button is clicked.
i understand i can add a custom button, but how do i write the code behind it, which will be triggered upon clicking.
the code behind the buttons needs to invoke this webservice, passing some details from the screen such as customer name and postcode, and the response that is received should be displayed on the screen.

please help people !
I have been trying to figure out how to do this without any luck - I want the user to be sent to a visualforce page when they select the lookup field on a custom object.
 
I have a "Quote" object.  When the user selects a custom button ("add new Quote product") they are sent to a visualforce page based on a custom object (horizonproduct) where they select a product.  They are then sent to the "Quote Products" page (which is a custom object) and the values from the visualforce page are filled in.
 
My problem is that if they then need to change that products, they are using the lookup for the horizonproduct object which does not take them back to the visualforce page. 
 
I want them to navigate back to the visualforce page so their selection can overwrite the values previously written.
 
Any help is greatly appreciated.  Thanks!!!
 
Fred
Hi guys,

I'm experiencing some unexpected behavior when trying to use the apex:repeat function to render tabs....

Basically it seems that tabs cannot be created on demand?  My controller is definitely returning data... as the second page block in my sample will show... repeat works - just the tabs are not rendered..

I'm sure any of you guys can see where I was going with this - and I guess I can achieve a similar result by dropping down to boring old html - just trying to use the standard components (as per best practice)

Any assistance greatly appreciated - as the purist coder me is seriously disturbed at the moment...

here is my 'simplified' and easily testable page & controller

Code: VF PAGE
<apex:page controller="clsRecordType">
    <apex:pageBlock >
        <apex:tabPanel id="theTabPanel">
            <apex:tab label="Account Types"/>
            <apex:repeat value="{!RecordTypes}" var="types">
                <apex:tab label="{!types.Name}"/>     
            </apex:repeat>
        </apex:tabPanel>
    </apex:pageBlock>

    <apex:pageBlock >
        <apex:repeat value="{!RecordTypes}" var="types">
            {!types.Name}<br/>       
        </apex:repeat>
    </apex:pageBlock>
</apex:page>

and the controller

Code:
public class clsRecordType {

    list<RecordType> lrecordtypes;

    public list<RecordType> getRecordTypes() {
        if(lrecordtypes==null) lrecordtypes = [Select Name, Id, Description From RecordType  where SobjectType = 'Account' and IsActive=True];
        return lrecordtypes;
        }
   }

 
 

Hi,

In my application(apex) i want:-

1)Certain values to be accessible to whole organization. Like an array of all countries and states etc. that would be used by all the users.

2) Certain values to be accessible in entire user's session. i.e. once set for one user session would be accessible to all classes when called from the same session. e.g. if I place user's company id in session/cache then it should be accessible across multiple pages(wherever user navigates). something like we do with Cache/Sessions in .NET/Java.

Please reply how to achieve the above mentioned features.

Thanks in advance,
A.V.
HI All,

I have created a VF Page and added that inside Account Detail page under a separete section.

The properties of the section are:
Name: Contact List
Column: 1
Tab Order: Top-Down
Show Section Heading On Detail Page: checked
Show Section Heading On Edit Page: checked

The properties of VF Page placed inside the section are:
Width: 100%
Height: 200px
Show Scrollbars: checked
Show label: unchecked

The output is as below:




The VF Page source code:
Code:
<apex:page standardController="Account">
<apex:pageBlock >
  {!Account.Name}
  <apex:pageBlockSection >  
  <apex:pageBlockTable value="{!Account.Contacts}" var="cnt">
    <apex:column value="{!cnt.Name}"/>
  </apex:pageBlockTable>
  </apex:pageBlockSection>
</apex:pageBlock>
</apex:page>

My problem is:
I don't want the white space below the page that is being displayed in above picture. If the list is too short the white space will be more. I want the page to cover the whole section.
What tag, attributes or settings help me to avoid the white section and cover the whole section.
Please help.

Thanks,
-Roshan



Hi All,
 
I've been looking at Visualforce, it looks very very cool, I'm excited about the prospects.
 
I wanted to create a simple page, it seems from my limited knowledge that it would be based on the standard controller 'Account'.
 
But I want to have an extra section just below the Contacts related list detail, that has an input field "Contact Name" and a button that has, Create New Contact.

So that a user could type a name text string in from the Accounts page, and then click the button, and a new contact will be created for them under this account, and they will return to the accounts page.
 
Can I do this with the standard controller? Or do I need a controller extension off the Accounts page which has a method to create a new Contact?
 
Any advice would be greatly appreciated.
 
Ryan
I keep getting this error time and again when I do a query from a SControl
 
"SOAPAction HTTP header missing".
 
There is no pattern...sometimes it comes and the next time it works fine.
 
Any help is appreciated.
 
Thanks
Rohit
How does one calculate time in Salesforce...
I tried:
Code:
<html>
<head>
<script type="text/javascript" src="/soap/ajax/10.0/connection.js"></script>
<script type="text/javascript"> 
function initpage()
{

var d = "{!Delivery_Time__c.Actual_Arrival_Time__c}";
var e = "{!Dispatch_Schedule__c.Arrival_Time__c}";

document.getElementById('div_tag').innerHTML = d.getTime() ;
}
</script>
</head>
<body bgcolor="#F3F3EC" onload="initpage()";> 
<font size="2" face="Verdana">
<div id="div_tag">Loading...</div></font>
</body>
</html>
that did not work... does anyone know the syntax
 

Hello Guys & Gals,
 
I thought I'd throw this out to the community as something that others might find useful.
 
I've had to implement this a number of times now - as no doubt some of you have already seen - there is no related list to show the opportunity contact roles for a 'contact'
 
This S-Control provides pretty much the same functionality.
 
Any suggestions to improve this are welcome... let me know if you find this useful.
 
Ben :)
 
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  "http://www.w3.org/TR/html4/loose.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>
<script src="/soap/ajax/10.0/connection.js" type="text/javascript"></script>
<script type="text/javascript" src="/js/functions.js"></script>
<script>
function Init() {

   //////////////////////////////////////////////////////////////////////////////////////////////////
   //                                                
   //             Developed March 2008   
   //               by Ben Ingram                    
   //           beningram@hotmail.com              
   //  May be re-used or altered so long as the credit remains :)                                              
   //                                                
   //                                                
   //  This s-Control for salesforce.com provides  
   //  visibility of all oportunities for which a  
   //  contact is listed as an Opportunity Contact 
   //                                                
   //  To Implement this s-Control:
   //    1. Add a new s-Control of type HTML
   //    2. Insert this code (all) into the HTML Body of the new Control
   //    3. Name the control something appropriate such as 'Contact_Opportunity_Roles'
   //    4. Edit the appropriate page layout for 'Contacts'
   //    5. Create a 'new section' to contain this inline s-control
   //       I recommend immediately preceding the related list area
   //    6. Drag the s-control from the list on the right into your new section
   //    7. Set the properties of this s-control to set the height = 100
   //    8. Enjoy :)
   //    
   //////////////////////////////////////////////////////////////////////////////////////////////////

  try{

    // Query the SOQL to return the related OpportunityContact records, along with the parent Opportunity details as required
    var SearchString="Select Id, ContactId, Role, IsPrimary, OpportunityId, Opportunity.Name, Opportunity.StageName From OpportunityContactRole Where ContactId = '{!Contact.Id}' ";
    var queryResults = sforce.connection.query(SearchString);
    var queryRecords = queryResults.getArray('records');
    var txtOutput = ""

    if (queryRecords.length > 0){
 
      // Rows returned, so first setup the column headers (hard coded - potentially revise this)
      var txtOutput = "<table class='list' width='100%' border='0' cellspacing='0' cellpadding='0'>";
      txtOutput = txtOutput + "<tr class='headerRow' height=20>";
      txtOutput = txtOutput + "<th nowrap>Opportunity</th>";
      txtOutput = txtOutput + "<th nowrap>Stage</th>";
      txtOutput = txtOutput + "<th nowrap>Role</th>";
      txtOutput = txtOutput + "<th nowrap>Is Primary</th></tr>";

      // Next Loop through the result array (row by row)
      for (var i = 0; i < queryRecords.length; i++) {

        // queryRecord = the Current row within the array
        var queryRecord = queryRecords[i];

        // OppRecord = the sub array row containing the linked Opportunity details
        var OppRecord = queryRecord.get("Opportunity");

 // Now build the results output row by row 
        txtOutput = txtOutput + "<tr class='dataRow' onmouseover=hiOn(this) onmouseout=hiOff(this)>";
        txtOutput = txtOutput + "<td class='datacell'><a href='/"+ queryRecord.get("OpportunityId") +"' target=_parent>" + OppRecord.get("Name") + "</a></td>";
        txtOutput = txtOutput + "<td> "+ OppRecord.get("StageName") + "</td>";
        txtOutput = txtOutput + "<td> "+ queryRecord.get("Role") + "</td>";

 // Display the standard grid checkbox image (checked or unchecked as appropriate)
        if(queryRecord.get("IsPrimary")=="true"){
          txtOutput = txtOutput + "<td><img src='/img/checkbox_checked.gif' alt='Checked' width='21' height='16' class='checkImg' title='Checked' /></td></tr>";} else {
          txtOutput = txtOutput + "<td><img src='/img/checkbox_unchecked.gif' alt='Not Checked' width='21' height='16' class='checkImg' title='Not Checked' /></td></tr>";
        } // end if (queryRecord.get("IsPrimary")=="true")
      } //end of array loop

     // Get rid of ugly white box by filling the gap with empty space 
     if (queryRecords.length == 1){
 txtOutput = txtOutput + "</table>&nbsp;<br> &nbsp;<br> &nbsp;";
 }
     if (queryRecords.length == 2){
 txtOutput = txtOutput + "</table>&nbsp;<br> &nbsp;";
 }
     if (queryRecords.length > 2){
 txtOutput = txtOutput + "</table>"; 
 }
    } else { 
      // there were no rows returnd from the SOQL query - so build a message to inform the user that this contact is not related to any opportunities
      txtOutput=txtOutput + "<font face = 'Verdana' size = '2'>This Contact has no specified Opportunity Contact Roles</font><br> &nbsp;<br> &nbsp;<br> &nbsp;<br> &nbsp;<br> &nbsp;<br>";
    }
 
  // Substitute the div mainBody contents for the generated HTML content
  document.getElementById("mainBody").innerHTML = txtOutput;

  }
  catch (error)
    {
      alert(error.faultstring);
    }
 
  }

</script>
</head>

<body class='account' onload="Init();" >
  <div class="bPageBlock secondaryPalette" style="border-top:0px; border-bottom:0px; margin-bottom:0px; padding-bottom:0px">
    <div id="mainBody"  class=pbBody style="margin-right:0px">
    </div>
  </div>
</body>
</html>