• D-Vac
  • NEWBIE
  • 25 Points
  • Member since 2010

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 9
    Replies
Hi I have a visualforce component with a controller I am trying to write test coverage on.  I had difficulty finding examples on testing the controller of a visualforce component.  One suggestion I read said to create a visualforce page with the controller simply to test it.  So that's what I've done but I could use some help.

Specifically, the controller and the page don't refer to a specific object / record.  They work if you go to the page itself and it queries the database for an aggregate result of opportunity information. 

I need help with the test coverage which is very flimsy and is getting the following error:
Class.Camp_Inf.CampDaysController_MP.Summary.<init>: line 31, column 1
Class.Camp_Inf.CampDaysController_MP.<init>: line 19, column 1
Class.Camp_Inf.testCampInfPages.Test2CampDaysController: line 80, column 1

Here is my controller:

public class CampDaysController_MP {

public Summary[] Summaries { get; set; }

public CampDaysController_MP(){

AggregateResult[] results =
                        [SELECT AVG(Camp_Inf__Days_from_Campaign_Start_to_Opp_Create__c) DayAvg
                         FROM Opportunity
                         WHERE CampaignId != null
                         AND CreatedDate = LAST_N_DAYS:365
                         //ORDER BY CreatedDate
                         //LIMIT 45000
                         ];

Summaries = New List<Summary>();

for (AggregateResult ar :results){
     Summaries.add(new Summary(ar));
     }
     }

                        
public class Summary{

public integer CampToOppDays {get; private set;}
public integer RecommendDays {get; private set;}

public Summary(AggregateResult ar){
Decimal CD = (Decimal) ar.get('DayAvg');
CampToOppDays = CD.intvalue();
Decimal RD = ((CD * 0.33)+ CD);
RecommendDays = RD.intvalue();
}

}
}

Here is the visualforce test page:

<apex:page controller="CampDaysController_MP" >
        <BR/>
        <apex:repeat value="{!Summaries}" var="s" > 
        <apex:outputtext value="Your company's average number of days from Campaign Start Date to Opportunity Create Date (for opportunities created in the last 365 days) is:"/>
        <BR/>
        <apex:outputtext value="{!s.CampToOppDays} days." style="font-size:Medium; color:red"/>
        <BR/>
        <BR/>          
        <apex:outputtext value="Therefore it is recommended you set the window at least at:"/>
        <BR/>
        <apex:outputtext value="{!s.RecommendDays} days." style="font-size:Medium; color:red"/>
        <BR/>
        </apex:repeat>    
</apex:page>


Here is my flimsy test coverage that doesn't work.  The main issue I think I am having is that I'm not able to do a ApexPages.currentPage().getParameters(); on a specific record like I'm used to doing.:

static testMethod void Test2CampDaysController() {

//this is a test utility I have to create some records
     Camp_Inf.TestCampInfUtils_MP t = new Camp_Inf.TestCampInfUtils_MP();
     t.StuffNoSettings(true);  

    
      Test.setCurrentPage(Page.Camp_Inf__CampToOppDaysComponentTester_MP);
  
Test.startTest();
   
      ApexPages.currentPage().getParameters();

      Camp_Inf.CampDaysController_MP idc2 = new Camp_Inf.CampDaysController_MP();

      
Test.stopTest();
}
//End of Test 2

Any help is much appreciated!  Thank you!
  • January 31, 2014
  • Like
  • 0

Hi, 

 

I have an object which is a child of an opportunity. "Child object".  The Child Object has a field called "Blah" which is a lookup to another object called "Blah".  

 

I am trying to come up with an Apex class to determine -- per opportunity -- which Blah record shows up the most number of times in the Child Object records. 

 

So for example: 

 

Opportunity A:

Child 1: Blah = Hat

Child 2: Blah = Coat

Child 3: Blah = Hat

Child 4: Blah = Hat

Child 5: Blah = Jim

 

How do you write a class that returns for Opportunity A, the value "Hat"?

 

Is it aggregateresult group by "Blah"?  How do you return the "Blah" value of the max rows of Blah value (and not just the number of Child Records for that Blah value)?  Do you return the aggregateresults and then query those results with an order by?

 

I figured there is probably a way to go about this which more experienced developers know.  

 

Any help?  I tried scowering the boards but couldn't quite find anything similar. 

 

Thank you!

  • September 20, 2013
  • Like
  • 0

Does anybody know how to create additional OpportunityShare records when converting a lead where the lead owner is different than the user who is converting the lead? 

 

I am trying to create opportunity share records which share the opportunity with other relevant users besides the opportunity owner and their management hierarchy. 

 

I know salesforce documentation says it runs the opportunity before triggers, etc... during lead convert.   That being said, it looks like it runs after insert triggers on the opportunity as well.  And possibly "after update"?

 

I'm trying to set the oppty shares during the Lead After Update trigger that creates the opportunity.  Everything works fine except that I believe that the opportunity owner "changes" before the Opportunity is committed to the database (i.e. from the running user to the lead owner) and therefore clears out any of the manual sharing added to the opportunity prior to the opportunity being committed to the database.  

 

Does anybody know the true order of execution during lead convert or any workarounds that allow re-triggering of the opportunity after it's been committed to the database so that the opportunityshare records can be added back on?

 

Thanks for any help!

 

 

  • January 09, 2013
  • Like
  • 0

I have a few visualforce pages I'm developing to be inline on a standard page layout.  

 

I can get my pages to dispay the normal validation rule errors if they are displayed on a specific field in <apex:pageMessages/>. 

 

However, if the validation rule error is supposed to be displayed on "Top of Page", it doesn't display anywhere.  I am guessing the errors want to display at the top of the standard page layout (not visualforce portion) but because the error is happening when i try to click what is essentially a quicksave button on the VF part it never gets to that step.

 

Does anybody know what I might be doing wrong or how to overcome this?

 

 

Here is my controller class:

public class OppVFPageSaveExtension
{

ApexPages.StandardController stdCtrl;
//global variables
private final Opportunity objOpportunity;
//end of global variables

//standard controller constructor     
    public OppVFPageSaveExtension(ApexPages.StandardController controller)
    {
    
    this.objOpportunity=(Opportunity)Controller.getrecord();
    stdCtrl=Controller;
    }
    //End of Standard Controller Constructor
    
    public Opportunity getOpp()
    {
     return (Opportunity) stdCtrl.getRecord();
    }
    
    //Method Called on to update Holiday
    Public PageReference save()
    {
    try
    {
    Update objOpportunity;
        PageReference OppPage=new PageReference('/'+getopp().id+'?inline=0');
         OppPage.SetRedirect(true);
         return OppPage; 
    }
    catch(System.DMLException e)
    { 
    return null;
    }
    Return NULL;
    }
    //end of Method Update Oppty
    
   }

 Here is my VF Page:

 

<apex:page standardController="Opportunity"  showHeader="true" tabStyle="Opportunity" extensions="OppVFPageSaveExtension">
<style>
         .activeTab {background-color: #E4C030; color:white; background-image:none}
         .inactiveTab { background-color: lightgrey; color:black; background-image:none}
</style>

<!--This part here is just for getting conditional qualification info on the opp, if required.  Otherwise it doesn't render-->
<apex:pageMessages />
 <apex:outputPanel id="QualPageBlock" rendered="{!(Opportunity.z_Has_this_opp_had_QualChecklistComplete__c == 0 && Opportunity.Does_Opp_Require_Qual_Profile__c == 1)}" >

  <apex:form >
 <apex:pageBlock title="Qualification Checklist" id="none">
  <apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Quick Save Changes"/>
</apex:pageBlockButtons>
<apex:pageMessages />
 <!--<apex:pageMessage severity="error">
 <apex:Messages />
 <apex:pageMessages />

 To access all the opportunity fields, please submit the following "Qualification Checklist".  
 <br/>
 The picklists are required; the details fields are optional</apex:pageMessage>-->

 <apex:pageBlockSection columns="3">
  <apex:OutputText >1. Are we the first in (are we setting the vision)?  If yes, describe the vision.</apex:OutputText>
 <apex:pageBlockSectionItem >
 <apex:inputField value="{!Opportunity.Qual1_AreWeFirstIn_PL__c}" required="true" style="text-align: left !important;padding-left: 2px !important;padding-right: 2px !important; width:98%;" >
<!--<apex:inlineEditSupport event="ondblclick"/>-->
</apex:inputField> 

 <apex:pageBlockSection columns="1" title="Please Select Strategic Business Impacts" id="SBIs">
 <!--<apex:inlineEditSupport event="ondblclick"/>-->
 <apex:inputField value="{!Opportunity.SBI_ICS__c}" />
 <apex:inputField value="{!Opportunity.SBI_IC__c}" />
 <apex:inputField value="{!Opportunity.SBI_IP__c}" />
 <apex:inputField value="{!Opportunity.SBI_IR__c}" />
 <apex:inputField value="{!Opportunity.SBI_IE__c}" />
 <apex:inputField value="{!Opportunity.SBI_DTTP__c}" />
 <apex:inputField value="{!Opportunity.SBI_ETR__c}" />
 <apex:inputField value="{!Opportunity.SBI_TFP__c}" />
 <apex:inputField value="{!Opportunity.SBI_CS__c}" />
 <apex:inputField value="{!Opportunity.SBI_CP__c}" />
 <apex:inputField value="{!Opportunity.SBI_Inn__c}" />
             </apex:pageBlockSection>
</apex:PageBlock>
      </apex:form>
</apex:outputPanel>


<!-- This is the default tabbed portion of the display and is also condition but is there most of the time -->
 <!--<apex:pageMessages />-->
 
       <apex:tabPanel switchType="client" selectedTab="name2" id="theTabPanel" tabClass="activeTab" inactiveTabClass="inactiveTab" 
       rendered="{!(Opportunity.z_Has_this_opp_had_QualChecklistComplete__c == 1 || Opportunity.Does_Opp_Require_Qual_Profile__c == 0)}">
       
          <apex:tab label="Field Sections">
             <apex:tabpanel switchType="client" tabClass="activeTab" inactiveTabClass="inactiveTab">         
            
          <apex:tab label="Relevant Personnel" name="Relevant_Personnel" id="ReleventPersonneltabFieldSet">               
             <apex:include pageName="Opp_ReleventPersonnelFieldSet"/>
          </apex:tab>

          <apex:tab label="Win/Loss Info" name="Win_Loss_Info" id="Opp_WinLossInfo">               
             <apex:include pageName="Opp_WinLossInfo"/>
          </apex:tab>
          
          </apex:tabPanel> 
          </apex:tab>
          
          
          <apex:tab label="Opportunity Team" name="Opportunity Team" id="TabTeam" rendered="{!(Opportunity.StageName <> 'Finalist')}">
             <apex:relatedList subject="{!Opportunity}" list="OpportunityTeamMembers" />
          </apex:tab>
          <!--<apex:tab label="Opportunities" name="Opportunities" id="tabOpp">
             <apex:relatedList subject="{!Opportunity}" list="opportunities" />
          </apex:tab>-->
          <apex:tab label="Strategic Account Plan" name="StrategicAccountPlan" id="tabSAPs">
             <apex:relatedList subject="{!Opportunity}" list="Strategic_Account_Plans__r" />
          </apex:tab>
          
          <apex:tab label="STAR Plan" name="STAR_Plan" id="STAR_Plan">               
          <apex:include pageName="Opp_Rel_SAPDetails"/>
          </apex:tab>
          
          <apex:tab label="Services Support Requests" name="Services Support Requests" id="tabSSRs">
             <apex:relatedList subject="{!Opportunity}" list="Request_Services_Support__r" />
          </apex:tab>
          <apex:tab label="Notes and Attachments" name="NotesAndAttachments" id="tabNoteAtt">
             <apex:relatedList subject="{!Opportunity}" list="NotesAndAttachments" />
          </apex:tab>
       </apex:tabPanel>
       
       

       
       
       
       
       
    </apex:page>

 

  • December 05, 2012
  • Like
  • 0

Hi, I'm trying to use this "Modal Dialogs in VF with the Yahoo! User Interface Library" code as a basis to make a popup open on a VF page when an Opportunity moves to the Stage = Qualified (or beyond):

 

http://wiki.developerforce.com/page/Tutorial:_Modal_Dialogs_in_Visualforce_using_the_Yahoo!_User_Interface_Library

 

Is there an easy way anybody knows of to forego the "onlick" button and instead use the attributes of the record itself to prompt the Modal Dialog to stop staying hidden?  So for example the opportunity record's stage is "Qualified" and/or a formula field evaluates to a certain value, therefore displaying the popup?

 

    <apex:pageBlockButtons >
        <input type="button" class="btn"
                   onclick="YAHOO.force.com.showMe();"
                    value="Popup Demo" />
    </apex:pageBlockButtons>
    

 

 

I've tried mashing in this Javascript code to no avail: http://boards.developerforce.com/t5/forums/forumtopicprintpage/board-id/Visualforce/message-id/44931/print-single-message/false/page/1

 

It's basically using js to query the record and then uses "window.open" to popup.  But I can't get it to work as a replacement for the button.

 

var arrId = '{!$CurrentPage.parameters.id}';
var queryresult = sforce.connection.query("Select Rating from account where id='"+arrId+"'");
var records = queryresult.getArray("records");

if(records[0].Active__c=='Warm')
{
window.open('/apex/searchcontact');
}

 

 

I've been reading Bob Buzzard and friends for the last few days and I can't seem to find the missing piece.

 

Here is my code so far.  There's an extra section which makes the account tabbed with the fields grouped into tabs by field sets.  I've made the tabs edit the fields as inline edits, so there isn't really much of a need for an edit screen. 

 

I'm guessing there needs to be a controller extension or something to make it happen?

 

Any nudges in the right direction are greatly appreciated!

 

 

<apex:page standardController="Opportunity" extensions="OppVFPageSaveExtension" showHeader="true" tabStyle="Opportunity" >
<style>
         .activeTab {background-color: #E4C030; color:white; background-image:none}
         .inactiveTab { background-color: lightgrey; color:black; background-image:none}
</style>



<apex:styleSheet value="http://yui.yahooapis.com/2.6.0/build/assets/skins/sam/skin.css" />
  
<apex:includeScript value="http://yui.yahooapis.com/2.6.0/build/yahoo-dom-event/yahoo-dom-event.js" />
<apex:includeScript value="http://yui.yahooapis.com/2.6.0/build/container/container-min.js" />
<apex:includeScript value="http://yui.yahooapis.com/2.6.0/build/animation/animation-min.js" />

<script>
    
  // Create a namespace for our custom functions
    YAHOO.namespace("force.com");
 
    // Function called when we want to show the dialog
    YAHOO.force.com.showMe = function() {
        document.getElementById("myPanel").style.display = "block";
        YAHOO.force.com.myDialog.show();
    }
    
    // Function called when we want to hide the dialog
    YAHOO.force.com.hideMe = function() {
       YAHOO.force.com.myDialog.hide();
    }
 
   // Function called when the DOM is ready to create the dialog,
    // render the dialog into the document body, add our dialog skin
    // css to the body tag, and wire up the buttons on our dialog   
    YAHOO.force.com.init = function() {
        document.body.className = document.body.className + " yui-skin-sam";
         
        YAHOO.force.com.myDialog = new YAHOO.widget.Panel(
            "myPanel",  // The id of our dialog container
            {
                    width           :   1000,    // You can play with this until it's right
                    visible         :   false,  // Should be invisible when rendered
                    draggable       :   true,   // Make the dialog draggable
                    close           :   false,  // Don't include a close title button
                    modal           :   true,   // Make it modal
                    fixedCenter     :   false,   // Keep centered if window is scrolled
                    zindex          :   40,     // Make sure it's on top of everything
                         
                    // This line adds the appear/vanish fade effect
                    effect          :   {
                                          effect:YAHOO.widget.ContainerEffect.FADE,
                                          duration:0.35
                                        }
            }
         );
         
        // Render the dialog to the document.body level of the DOM
        YAHOO.force.com.myDialog.render(document.body);
    }
     
    // Add the init method to the window.load event
    YAHOO.util.Event.addListener(window, "load", YAHOO.force.com.init);
</script>

 <apex:outputPanel >
 <apex:pageBlock title="Basic Modal Dialog" id="none">
    <apex:pageBlockButtons >
        <input type="button" class="btn"
                   onclick="YAHOO.force.com.showMe();"
                    value="Popup Demo" />
    </apex:pageBlockButtons>
      </apex:pageBlock>
</apex:outputPanel>

<!--This is my Tabs VF--> <apex:tabPanel switchType="client" selectedTab="name2" id="theTabPanel" tabClass="activeTab" inactiveTabClass="inactiveTab"> <apex:tab label="Relevant Personnel" name="Relevant_Personnel" id="ReleventPersonneltabFieldSet"> <apex:include pageName="Opp_ReleventPersonnelFieldSet"/> </apex:tab> <apex:tab label="Win/Loss Info" name="Win_Loss_Info" id="Opp_WinLossInfo"> <apex:include pageName="Opp_WinLossInfo"/> </apex:tab> <apex:tab label="Opportunity Team" name="Opportunity Team" id="TabTeam"> <apex:relatedList subject="{!Opportunity}" list="OpportunityTeamMembers" /> </apex:tab> <!--<apex:tab label="Opportunities" name="Opportunities" id="tabOpp"> <apex:relatedList subject="{!Opportunity}" list="opportunities" /> </apex:tab>--> <apex:tab label="SSRs" name="SSRs" id="tabSSRs"> <apex:relatedList subject="{!Opportunity}" list="Request_Services_Support__r" /> </apex:tab> <apex:tab label="Notes and Attachments" name="NotesAndAttachments" id="tabNoteAtt"> <apex:relatedList subject="{!Opportunity}" list="NotesAndAttachments" /> </apex:tab> </apex:tabPanel> <!-- This is the content of the modal dialog --> <div id="myPanel" style="display: none" > <div class="hd"> <apex:outputText value="Opp Qualification Profile" /> </div> <div class="ft" style="font-size: 10px;"> <apex:outputPanel layout="block"> Please enter what you know. Once you close this, you still need to click "Quick Save" to save changes. </apex:outputPanel> </div> <div class="bd"> <apex:form > <apex:pageBlock > <apex:pageBlockSection columns="1"> <apex:inputField id="fDescription" value="{!opportunity.Description}" /> </apex:pageBlockSection> </apex:pageBlock> <div style="text-align: right;" > <apex:commandButton value="Close (You will still need to click save once this closes)" oncomplete="YAHOO.force.com.hideMe();" /> <apex:commandButton value="Cancel" immediate="true" oncomplete="YAHOO.force.com.hideMe();"/> </div> </apex:form> </div> <br/> <br/> </div> </apex:page>

 

 

 

 

  • October 31, 2012
  • Like
  • 0

Does anyone have any Apex code (or ideas) that could be run prior to the web-to-lead assignment rules that would: 

 

- Query for any accounts of the same name as the "Company Name" field in the lead  

 

- Determine if it is a "named" account based on an account field 

 

- Assign the lead to the account owner OR another designated user based on the account owner (like inside sales)

 

This would be really helpful for us in situations where we have named accounts that are outside the normal lead / territory assignments.  

 

Thanks for any code, help or ideas!

  • February 09, 2010
  • Like
  • 0
Hi I have a visualforce component with a controller I am trying to write test coverage on.  I had difficulty finding examples on testing the controller of a visualforce component.  One suggestion I read said to create a visualforce page with the controller simply to test it.  So that's what I've done but I could use some help.

Specifically, the controller and the page don't refer to a specific object / record.  They work if you go to the page itself and it queries the database for an aggregate result of opportunity information. 

I need help with the test coverage which is very flimsy and is getting the following error:
Class.Camp_Inf.CampDaysController_MP.Summary.<init>: line 31, column 1
Class.Camp_Inf.CampDaysController_MP.<init>: line 19, column 1
Class.Camp_Inf.testCampInfPages.Test2CampDaysController: line 80, column 1

Here is my controller:

public class CampDaysController_MP {

public Summary[] Summaries { get; set; }

public CampDaysController_MP(){

AggregateResult[] results =
                        [SELECT AVG(Camp_Inf__Days_from_Campaign_Start_to_Opp_Create__c) DayAvg
                         FROM Opportunity
                         WHERE CampaignId != null
                         AND CreatedDate = LAST_N_DAYS:365
                         //ORDER BY CreatedDate
                         //LIMIT 45000
                         ];

Summaries = New List<Summary>();

for (AggregateResult ar :results){
     Summaries.add(new Summary(ar));
     }
     }

                        
public class Summary{

public integer CampToOppDays {get; private set;}
public integer RecommendDays {get; private set;}

public Summary(AggregateResult ar){
Decimal CD = (Decimal) ar.get('DayAvg');
CampToOppDays = CD.intvalue();
Decimal RD = ((CD * 0.33)+ CD);
RecommendDays = RD.intvalue();
}

}
}

Here is the visualforce test page:

<apex:page controller="CampDaysController_MP" >
        <BR/>
        <apex:repeat value="{!Summaries}" var="s" > 
        <apex:outputtext value="Your company's average number of days from Campaign Start Date to Opportunity Create Date (for opportunities created in the last 365 days) is:"/>
        <BR/>
        <apex:outputtext value="{!s.CampToOppDays} days." style="font-size:Medium; color:red"/>
        <BR/>
        <BR/>          
        <apex:outputtext value="Therefore it is recommended you set the window at least at:"/>
        <BR/>
        <apex:outputtext value="{!s.RecommendDays} days." style="font-size:Medium; color:red"/>
        <BR/>
        </apex:repeat>    
</apex:page>


Here is my flimsy test coverage that doesn't work.  The main issue I think I am having is that I'm not able to do a ApexPages.currentPage().getParameters(); on a specific record like I'm used to doing.:

static testMethod void Test2CampDaysController() {

//this is a test utility I have to create some records
     Camp_Inf.TestCampInfUtils_MP t = new Camp_Inf.TestCampInfUtils_MP();
     t.StuffNoSettings(true);  

    
      Test.setCurrentPage(Page.Camp_Inf__CampToOppDaysComponentTester_MP);
  
Test.startTest();
   
      ApexPages.currentPage().getParameters();

      Camp_Inf.CampDaysController_MP idc2 = new Camp_Inf.CampDaysController_MP();

      
Test.stopTest();
}
//End of Test 2

Any help is much appreciated!  Thank you!
  • January 31, 2014
  • Like
  • 0

Hi, 

 

I have an object which is a child of an opportunity. "Child object".  The Child Object has a field called "Blah" which is a lookup to another object called "Blah".  

 

I am trying to come up with an Apex class to determine -- per opportunity -- which Blah record shows up the most number of times in the Child Object records. 

 

So for example: 

 

Opportunity A:

Child 1: Blah = Hat

Child 2: Blah = Coat

Child 3: Blah = Hat

Child 4: Blah = Hat

Child 5: Blah = Jim

 

How do you write a class that returns for Opportunity A, the value "Hat"?

 

Is it aggregateresult group by "Blah"?  How do you return the "Blah" value of the max rows of Blah value (and not just the number of Child Records for that Blah value)?  Do you return the aggregateresults and then query those results with an order by?

 

I figured there is probably a way to go about this which more experienced developers know.  

 

Any help?  I tried scowering the boards but couldn't quite find anything similar. 

 

Thank you!

  • September 20, 2013
  • Like
  • 0

Does anybody know how to create additional OpportunityShare records when converting a lead where the lead owner is different than the user who is converting the lead? 

 

I am trying to create opportunity share records which share the opportunity with other relevant users besides the opportunity owner and their management hierarchy. 

 

I know salesforce documentation says it runs the opportunity before triggers, etc... during lead convert.   That being said, it looks like it runs after insert triggers on the opportunity as well.  And possibly "after update"?

 

I'm trying to set the oppty shares during the Lead After Update trigger that creates the opportunity.  Everything works fine except that I believe that the opportunity owner "changes" before the Opportunity is committed to the database (i.e. from the running user to the lead owner) and therefore clears out any of the manual sharing added to the opportunity prior to the opportunity being committed to the database.  

 

Does anybody know the true order of execution during lead convert or any workarounds that allow re-triggering of the opportunity after it's been committed to the database so that the opportunityshare records can be added back on?

 

Thanks for any help!

 

 

  • January 09, 2013
  • Like
  • 0

Hi, I'm trying to use this "Modal Dialogs in VF with the Yahoo! User Interface Library" code as a basis to make a popup open on a VF page when an Opportunity moves to the Stage = Qualified (or beyond):

 

http://wiki.developerforce.com/page/Tutorial:_Modal_Dialogs_in_Visualforce_using_the_Yahoo!_User_Interface_Library

 

Is there an easy way anybody knows of to forego the "onlick" button and instead use the attributes of the record itself to prompt the Modal Dialog to stop staying hidden?  So for example the opportunity record's stage is "Qualified" and/or a formula field evaluates to a certain value, therefore displaying the popup?

 

    <apex:pageBlockButtons >
        <input type="button" class="btn"
                   onclick="YAHOO.force.com.showMe();"
                    value="Popup Demo" />
    </apex:pageBlockButtons>
    

 

 

I've tried mashing in this Javascript code to no avail: http://boards.developerforce.com/t5/forums/forumtopicprintpage/board-id/Visualforce/message-id/44931/print-single-message/false/page/1

 

It's basically using js to query the record and then uses "window.open" to popup.  But I can't get it to work as a replacement for the button.

 

var arrId = '{!$CurrentPage.parameters.id}';
var queryresult = sforce.connection.query("Select Rating from account where id='"+arrId+"'");
var records = queryresult.getArray("records");

if(records[0].Active__c=='Warm')
{
window.open('/apex/searchcontact');
}

 

 

I've been reading Bob Buzzard and friends for the last few days and I can't seem to find the missing piece.

 

Here is my code so far.  There's an extra section which makes the account tabbed with the fields grouped into tabs by field sets.  I've made the tabs edit the fields as inline edits, so there isn't really much of a need for an edit screen. 

 

I'm guessing there needs to be a controller extension or something to make it happen?

 

Any nudges in the right direction are greatly appreciated!

 

 

<apex:page standardController="Opportunity" extensions="OppVFPageSaveExtension" showHeader="true" tabStyle="Opportunity" >
<style>
         .activeTab {background-color: #E4C030; color:white; background-image:none}
         .inactiveTab { background-color: lightgrey; color:black; background-image:none}
</style>



<apex:styleSheet value="http://yui.yahooapis.com/2.6.0/build/assets/skins/sam/skin.css" />
  
<apex:includeScript value="http://yui.yahooapis.com/2.6.0/build/yahoo-dom-event/yahoo-dom-event.js" />
<apex:includeScript value="http://yui.yahooapis.com/2.6.0/build/container/container-min.js" />
<apex:includeScript value="http://yui.yahooapis.com/2.6.0/build/animation/animation-min.js" />

<script>
    
  // Create a namespace for our custom functions
    YAHOO.namespace("force.com");
 
    // Function called when we want to show the dialog
    YAHOO.force.com.showMe = function() {
        document.getElementById("myPanel").style.display = "block";
        YAHOO.force.com.myDialog.show();
    }
    
    // Function called when we want to hide the dialog
    YAHOO.force.com.hideMe = function() {
       YAHOO.force.com.myDialog.hide();
    }
 
   // Function called when the DOM is ready to create the dialog,
    // render the dialog into the document body, add our dialog skin
    // css to the body tag, and wire up the buttons on our dialog   
    YAHOO.force.com.init = function() {
        document.body.className = document.body.className + " yui-skin-sam";
         
        YAHOO.force.com.myDialog = new YAHOO.widget.Panel(
            "myPanel",  // The id of our dialog container
            {
                    width           :   1000,    // You can play with this until it's right
                    visible         :   false,  // Should be invisible when rendered
                    draggable       :   true,   // Make the dialog draggable
                    close           :   false,  // Don't include a close title button
                    modal           :   true,   // Make it modal
                    fixedCenter     :   false,   // Keep centered if window is scrolled
                    zindex          :   40,     // Make sure it's on top of everything
                         
                    // This line adds the appear/vanish fade effect
                    effect          :   {
                                          effect:YAHOO.widget.ContainerEffect.FADE,
                                          duration:0.35
                                        }
            }
         );
         
        // Render the dialog to the document.body level of the DOM
        YAHOO.force.com.myDialog.render(document.body);
    }
     
    // Add the init method to the window.load event
    YAHOO.util.Event.addListener(window, "load", YAHOO.force.com.init);
</script>

 <apex:outputPanel >
 <apex:pageBlock title="Basic Modal Dialog" id="none">
    <apex:pageBlockButtons >
        <input type="button" class="btn"
                   onclick="YAHOO.force.com.showMe();"
                    value="Popup Demo" />
    </apex:pageBlockButtons>
      </apex:pageBlock>
</apex:outputPanel>

<!--This is my Tabs VF--> <apex:tabPanel switchType="client" selectedTab="name2" id="theTabPanel" tabClass="activeTab" inactiveTabClass="inactiveTab"> <apex:tab label="Relevant Personnel" name="Relevant_Personnel" id="ReleventPersonneltabFieldSet"> <apex:include pageName="Opp_ReleventPersonnelFieldSet"/> </apex:tab> <apex:tab label="Win/Loss Info" name="Win_Loss_Info" id="Opp_WinLossInfo"> <apex:include pageName="Opp_WinLossInfo"/> </apex:tab> <apex:tab label="Opportunity Team" name="Opportunity Team" id="TabTeam"> <apex:relatedList subject="{!Opportunity}" list="OpportunityTeamMembers" /> </apex:tab> <!--<apex:tab label="Opportunities" name="Opportunities" id="tabOpp"> <apex:relatedList subject="{!Opportunity}" list="opportunities" /> </apex:tab>--> <apex:tab label="SSRs" name="SSRs" id="tabSSRs"> <apex:relatedList subject="{!Opportunity}" list="Request_Services_Support__r" /> </apex:tab> <apex:tab label="Notes and Attachments" name="NotesAndAttachments" id="tabNoteAtt"> <apex:relatedList subject="{!Opportunity}" list="NotesAndAttachments" /> </apex:tab> </apex:tabPanel> <!-- This is the content of the modal dialog --> <div id="myPanel" style="display: none" > <div class="hd"> <apex:outputText value="Opp Qualification Profile" /> </div> <div class="ft" style="font-size: 10px;"> <apex:outputPanel layout="block"> Please enter what you know. Once you close this, you still need to click "Quick Save" to save changes. </apex:outputPanel> </div> <div class="bd"> <apex:form > <apex:pageBlock > <apex:pageBlockSection columns="1"> <apex:inputField id="fDescription" value="{!opportunity.Description}" /> </apex:pageBlockSection> </apex:pageBlock> <div style="text-align: right;" > <apex:commandButton value="Close (You will still need to click save once this closes)" oncomplete="YAHOO.force.com.hideMe();" /> <apex:commandButton value="Cancel" immediate="true" oncomplete="YAHOO.force.com.hideMe();"/> </div> </apex:form> </div> <br/> <br/> </div> </apex:page>

 

 

 

 

  • October 31, 2012
  • Like
  • 0

Does anyone have any Apex code (or ideas) that could be run prior to the web-to-lead assignment rules that would: 

 

- Query for any accounts of the same name as the "Company Name" field in the lead  

 

- Determine if it is a "named" account based on an account field 

 

- Assign the lead to the account owner OR another designated user based on the account owner (like inside sales)

 

This would be really helpful for us in situations where we have named accounts that are outside the normal lead / territory assignments.  

 

Thanks for any code, help or ideas!

  • February 09, 2010
  • Like
  • 0
I want to send an email thanking the Primary Contact on an Opportunity when we mark the corresponding Opportunity Closed Won. But I don't see that object (Opportunity Contact Role) as an option when setting up the email alert.

Any suggestions?

Jane

  • October 24, 2008
  • Like
  • 0