• sravu
  • SMARTIE
  • 797 Points
  • Member since 2010

  • Chatter
    Feed
  • 31
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 35
    Questions
  • 189
    Replies

I would like a value from the visual force page to be transfered to the controller. It seems like the value from the command button is not being transfers. Can someone please help or tell me what I have done wrong. 

 

Here is the section fo the controller. 

 

 

public class SearchController {

    public String Searchtxt {get; set;}
    public Boolean Checkbox {get; set;}
    public String jobSelect {get; set;}
    List<Job__c> joblist = [SELECT Name, Bounty__c, Bounty_Other__c, Bounty_Rules__c FROM Job__c ORDER BY Name];
    
    public List<Job__c> getJob(){
        return joblist;
    }
    public Referral__c referral{
    get{if(referral == null) referral = new Referral__c();  
    referral.Referee__c = ApexPages.currentPage().getParameters().get('id');
    return referral;} set;}
    
    public PageReference SearchId() {
        joblist = [SELECT Name, Bounty__c, Bounty_Other__c, Bounty_Rules__c FROM Job__c WHERE Name =:Searchtxt];
        if(Searchtxt == '' || Searchtxt == null) joblist = [SELECT Name, Bounty__c, Bounty_Other__c, Bounty_Rules__c FROM Job__c ORDER BY Name];
        return null;
    }
    
        public PageReference Referral() {
            jobSelect = ApexPages.currentPage().getParameters().get('id'); 
            for(Job__c j : joblist){
                if(j.id == jobSelect) referral.Job__c = j.Id;
            }
            insert referral;
            PageReference tosecondpage = Page.leadstep1;
            tosecondpage.getParameters().put('Id',referral.Id);
            tosecondpage.setRedirect(true);
            return tosecondpage;
    }
    
    
}

 

 

Here is the Visual Force Page. 

 

<apex:page tabStyle="Job__c" controller="SearchController">
    <apex:form >
        <apex:sectionHeader title="Choosing a Job!"/>
        <apex:pageBlock >
            <apex:pageBlockSection title="Search Job Ids">
                <apex:outputLabel value="If you know the Job Id please enter it here and click 'Search'" for="Search">
                    <br/>
                    <apex:inputText id="Search" value="{!Searchtxt}"/>
                </apex:outputLabel>
                    <br/>
                    <apex:commandButton value="Search" action="{!SearchId}"/>
                    <br/>
                    <apex:commandButton value="Referral" action="{!Referral}"/>
            </apex:pageBlockSection>
            <apex:pageBlockTable value="{!job}" var="item">
                <apex:column width="1%">
                    <apex:inputCheckbox value="{!Checkbox}"/>
                </apex:column>
                <apex:column value="{!item.Name}" width="5%"/>
                <apex:column value="{!item.Bounty__c}" width="5%"/>
                <apex:column value="{!item.Bounty_Other__c}" width="5%"/>
                <apex:column value="{!item.Bounty_Rules__c}" width="5%"/>
                <apex:column width="1%">
                    <apex:commandButton value="About" onclick="window.open('/{!item.Id}');return false;"/>
                    <apex:commandButton value="Referral" action="{!referral}">
                        <apex:param name="jobSelect" value="{!item.Id}"/>
                    </apex:commandButton>
                </apex:column>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

 

 

 

I have a VF page with a standard controller and extension controller.  I'm using the tabPanel and tab controls, but the tabs do not display (only the text of the tab) and you can't click on the text of the tab to move from one tab to another.

 

Page:

 

<apex:page standardController="Lead" extensions="DispatcherLeadViewController" action="{!nullValue(redir.url, urlFor($Action.Lead.View, lead.id, null, true))}" showHeader="true" tabStyle="lead">
    <apex:tabPanel switchType="client" selectedTab="name1" id="theTabPanel">
        <apex:tab label="One" name="name1" id="tabOne">
        	<apex:outputField value="{!Lead.FirstName}" />
        </apex:tab>
        <apex:tab label="Two" name="name2" id="tabTwo">
        	<apex:outputField value="{!Lead.LastName}" />
        </apex:tab>
    </apex:tabPanel>
</apex:page>

 

controller:

 

public class DispatcherLeadViewController {
	
	private final ApexPages.StandardController controller;
	
	public DispatcherLeadViewController(ApexPages.StandardController controller) {
		this.controller = controller;
	}
	
	public PageReference getRedir() {
 
		Lead l = [Select id, recordtypeid From Lead Where Id = :ApexPages.currentPage().getParameters().get('id')];
 
		PageReference newPage;
 
		if (l.recordtypeid == '012400000005S9QAAU') {
			system.debug('We are here');
			newPage = Page.LeadViewTabbed;
			system.debug('************************* ' + newPage);
		} else {
			newPage = new PageReference('/' + l.id);
			newPage.getParameters().put('nooverride', '1');
		}
 
		newPage.getParameters().put('id', l.id);
		system.debug('********************** ' + newPage);
		return newPage.setRedirect(true);
 
	}
	
}

The problem appears to be related to the action attribute in the apex:page control.  If I remove that attribute, the tabs display fine, but then I am not able to display the visualforce page for a specific recordtype.  The visualforce page displays for every recordtype, which is not what I need to happen. 

 

Any help is appreciated.

Thanks.

Hi,

 

I am trying to make the default picklist value of LeadSource to "WEB". Can I be assisted?

 

Below is the code.

 

<apex:pageBlockSection title="" collapsible="false" columns="1" >
    <br /><br />
    
    


   
         <apex:inputField value="{!Lead.LeadSource}" />  <----picklist value default to "WEB"              
         
         
         
         <apex:inputfield value="{!Lead.Industry}" required="true"/>     
         <apex:inputField value="{!Lead.Title}"/>
         <apex:inputField value="{!Lead.Salutation}"/>
         <apex:inputField value="{!Lead.FirstName}" required="true"/>
         <apex:inputField value="{!Lead.LastName}"/>         
         <apex:inputField value="{!Lead.Company}"/>
         <apex:inputField value="{!Lead.Street}" required="true"/>
         <apex:inputField value="{!Lead.City}" required="true"/>
         <apex:inputField value="{!Lead.State}" required="true"/>
         <apex:inputField value="{!Lead.PostalCode}" required="true"/>
         <apex:inputField value="{!Lead.Email}" required="true"/>
         <apex:inputField value="{!Lead.Phone}" required="true"/> 
            
       <br /><br />
              </apex:pageBlockSection>

 

  • March 17, 2011
  • Like
  • 0

Hello.  I have run into what I think is a pretty simple formatting question...but I have no idea how to accomplish what I want.

 

In short, I want to display four pieces of data within a PageBlock (an employee's name, age, birthday, birthplace).  These are not inputFields...but instead the values of variables.  My goal is to display this information on two lines...I would like for the name and age to display on the first line...and the birthday and birthplace to display on the second line.

 

Unfortunately, what I have below looks messy (the top right column does not always align with the bottom right column).  I tried using the <apex:column> command...but this only works for data tables (and I am obviously not displaying a table of records here).

 

Any suggestios on how to get this information to line up would be much appreciated.

 

<apex:pageBlockSection title="Employee Details" columns="2">
<apex:pageBlockSectionItem >
<b>Name: </b> {!EmpName}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<b>Age:</b> {!EmpAge}
<b>Birthdate: </b> {!EmpBDay}
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<b>Birthplace: </b> {!EmpBPlace}
</apex:pageBlockSectionItem>
</apex:pageBlockSection>

 

 

 

 

Hi, I'm trying to create a report in a visualforce page for a custom object called Skills__c.

What I'm wanting to get is a table to show how many times a picklist option has been selected in a picklist called skill__c, to help understand what I mean here is an example:

 

Skill Total

Attention to Detail 5

Time Management 2

Reporting 1

 

Something like that.

 

So my question is, does anyone know any places I can find how to do this, I've found a few examples but not for custom objects and I'm struggling to change them. 

 

Thanks

 

Ezmo

  • March 16, 2011
  • Like
  • 0

Hi,

 

I have two objects, Opportunity and Pricing_Support__c. Both are related via lookup.

I have created a visualforce page which will then render pageblocks based on the user selection.

 

when i select the stagename, i can render a pageblock which has a field of Pricing_Support__c object.

Now, when i select a value from the above rendered field, i am unable to render another pageblock dynamically. The one in Red color below.

 

Any pointers/idea/help on this is highly appreciated.

 

FYI, the visualforce page has a standardcontroller of opportunity and a controllerextension.

 

VF Page:

<apex:page standardController="Opportunity" extensions="pricingSupport" >
      <apex:form >
          <apex:pageBlock title="Enter Opportunity Information">
              <apex:pageBlockButtons location="bottom">
                  <apex:commandButton value="Save" action="{!Save}"/>
                  <apex:commandButton value="Cancel" action="{!Cancel}" immediate="true"/>                                
              </apex:pageBlockButtons>
              <apex:PageblockSection columns="1" >
                      <apex:inputField value="{!Opportunity.Name}"/>
                     <apex:PageBlockSectionItem >
                         <apex:outputLabel value="Stage"/>
                         <apex:actionRegion >
                          <apex:inputField value="{!Opportunity.StageName}">
                          <apex:actionSupport event="onchange" reRender="ajaxrequest" status="RefreshStatus" />
                          
                          </apex:inputField>
                         </apex:actionRegion>
                      </apex:PageBlockSectionItem>
                  </apex:PageblockSection>
              <apex:outputPanel id="ajaxrequest">   
                  <apex:pageBlockSection rendered="{!Opportunity.StageName=='Prospecting'|| Opportunity.StageName!=Null}" > 
                      <apex:PageBlockSectionItem >    
                          <apex:outputLabel value="Contract Scenario"/>
                          <apex:actionRegion >                 
                              <apex:inputField value="{!priceSupport.Contract_Scenario__c}"> 
                                  <apex:actionSupport event="onchange" reRender="ajaxrequest2" status="RefreshStatus"/>
                               </apex:inputField>
                          </apex:actionRegion>  
                      </apex:PageBlockSectionItem>         
                  </apex:pageBlockSection>
              </apex:outputPanel> 
              
              <apex:outputPanel id="ajaxrequest2">   
                  <apex:pageBlockSection title="Rendered" rendered="{!priceSupport.Contract_Scenario__c=='1.Existing Contract / Contract Expansion'}" > 
                     <apex:inputField value="{!Opportunity.CloseDate}"/>
                  </apex:pageBlockSection>
              </apex:outputPanel> 
          </apex:pageBlock>
      </apex:form>
    
</apex:page>

 

Apex class(controller extension):

 

public class pricingSupport {

    Public Pricing_Support__c priceSupport {get;set;}
    public pricingSupport(ApexPages.StandardController controller) {

    }
    
    Public pageReference saveAction(){
        return Null;
    }
    
     Public pageReference cancelAction(){
        return Null;
    }

}

 

 

Thanks,

Sales4ce

Hello,

 

I have a visualforce page with a command Button. When this is pressed some work is done in the page-reference of the controller-extension. During this work it is sometimes necessary to open new Windows in which are PDF-Documents are generated and diplayed. Is it possible to open a second, third, forth ... window with a visualforce page rendered as PDF directly from the apex code without leaving the original window. In the pagereference I think, I can only pass one new page, which is then displayed in the actual window, but I want to stay on this window with the original content and open the others for the user, who can then print them?

 

Thanks

Harry

Hey all,

 

I had this working, made a few changes, and can not for the life of me find now why it will not work.  I am creating a VF page that will rend on the lead layout.  Simple Page that will show all lead records that have the same email address on the page layout and a few fields from the lead.

 

At one point this all worked, and I've buggered something up.  Thanks for the help!

 

Error I'm getting "Content cannot be displayed: SObject row was retrieved via SOQL without querying the requested field: Lead.Email"

 

Here is the controller:

 

public class LeadLookupCon {
    
    public Lead lookupLead;
    
    List<Lead> leads;
    public String sortField {get; set;}
    public String previousSortField {get; set;}   
    
    public LeadLookupCon(ApexPages.StandardController controller) {
        this.lookupLead = (Lead)controller.getRecord();
    }

    public List<Lead> getLeads() {
        if(leads == null) leads = [select id,createddate,name,company, email,LeadSource, Event_Name__c,productinterest__c,inquiry_stage__c from lead where email=:lookupLead.email ORDER BY createddate desc];
        return leads;
    }
    
    public void doSort(){
        String order = 'asc';
        /*This checks to see if the same header was click two times in a row, if so it switches the order.*/
        if(previousSortField == sortField){
            order = 'desc';
            previousSortField = null;
        }else{
            previousSortField = sortField;
        }
        adbeSort.sortList(leads,sortField,order);

    }
}

 

 

Here is the VF Page:

<apex:page standardController="Lead" extensions="LeadLookupCon" standardStylesheets="true" showHeader="false" sidebar="false" tabStyle="Lead">
    <style>
        .even { background: #fff;}
    </style>
    <apex:form >
    <apex:pageBlock title="Previous Engagement History" tabStyle="Lead" >
        <apex:pageBlockTable value="{!leads}" var="lead" id="theTable" rowClasses="odd,even" styleClass="tableClass" cellpadding="5" width="100%">
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="{!$ObjectType.Lead.Fields.Company.Label}" action="{!doSort}" rerender="theTable">
                            <apex:param name="sortField" value="Company" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputText value="{!lead.company}"/>
            </apex:column>
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="{!$ObjectType.Lead.Fields.Name.Label}" action="{!doSort}" rerender="theTable">
                            <apex:param name="sortField" value="Name" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputLink value="/{!lead.id}">{!lead.name}</apex:outputLink>
            </apex:column>
            <apex:column >
                <apex:facet name="header">{!$ObjectType.Lead.Fields.Email.Label}</apex:facet>
                <apex:outputLink value="/{!lead.id}">{!lead.Email}</apex:outputLink>
            </apex:column>
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="{!$ObjectType.Lead.Fields.ProductInterest__c.Label}" action="{!doSort}" rerender="theTable">
                        <apex:param name="sortField" value="ProductInterest__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputText value="{!lead.ProductInterest__c}"/>
            </apex:column>
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="{!$ObjectType.Lead.Fields.LeadSource.Label}" action="{!doSort}" rerender="theTable">
                        <apex:param name="sortField" value="LeadSource" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputText value="{!lead.leadsource}"/>
            </apex:column>
            <apex:column >
                <apex:facet name="header">
                    <apex:commandLink value="{!$ObjectType.Lead.Fields.Event_Name__c.Label}" action="{!doSort}" rerender="theTable">
                        <apex:param name="sortField" value="Event_Name__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputText value="{!lead.Event_Name__c}"/>
            </apex:column>
            <apex:column width="75px" >
                <apex:facet name="header">
                    <apex:commandLink value="{!$ObjectType.Lead.Fields.Inquiry_Stage__c.Label}" action="{!doSort}" rerender="theTable">
                        <apex:param name="sortField" value="Inquiry_Stage__c" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputText value="{!lead.Inquiry_Stage__c}"/>
            </apex:column>
            <apex:column width="100px" >
                <apex:facet name="header">
                    <apex:commandLink value="{!$ObjectType.Lead.Fields.createddate.Label}" action="{!doSort}" rerender="theTable">
                        <apex:param name="sortField" value="createddate" assignTo="{!sortField}"/>
                    </apex:commandLink>
                </apex:facet>
                <apex:outputText value="{!lead.createddate}"/>
            </apex:column>
        </apex:pageBlockTable>
    </apex:pageBlock>
    </apex:form>
</apex:page>

 

:

 

 

 

Hello, I am trying to build a simple proof of concept whereby a hyperlink on an in-line visualforace page on the Task creates a new Opportunity when clicked.

 

I have what I think should be workable code. However, the inline visual force page that I want to show up on the task is displaying "Content cannot be displayed: DML currently not allowed".

 

What I would expect to be displayed is a hyperlink on the text "Create New Opp".

 

This is my visualforce page code:

 

<apex:page standardController="Task" extensions="OppClass">
  <!-- Begin Default Content REMOVE THIS -->
  <h1>Q1 2011 Upsell</h1>
Create new opportunity with this campaign:
<!-- My Stufff -->
    <apex:form >
    <apex:commandLink action="!Ops" value="Create New Opp" id="comlink1"/>
    </apex:form>
<!-- END MY STUFF-->
  <!-- End Default Content REMOVE THIS -->
</apex:page>

 

 

My apex code is this (intended to execute when one clicks on the above link):

 

public without sharing class OppClass
{

    public OppClass(ApexPages.StandardController controller) {
    NewOpp();
    }

    public void NewOpp(){
        Opportunity o = new Opportunity(name = 'Acme');
        Database.SaveResult[] lsr = Database.insert(new Opportunity[]{o, new Opportunity(name = 'Acme')},false);
    }
}

 

This is intended to be a simplified proof of concept, but I can't see where I am failing. Does anyone have any suggestions?

Could it be permission settings somewhere in my developer environment? 

 

 

Thanks,

IW

 

  • January 24, 2011
  • Like
  • 0

Hi - I am new to APEX, I have a query that looks like this. What am I doing wrong and how do I write a test case.

 

Thanks

 

 

public class GroupedQuery
{
    public string GroupBy1     {get;set;}
    public string GroupBy2     {get;set;}
    public string GroupBy3     {get;set;}
    public integer Count {get;set;}
    public Decimal Sum {get;set;}
    public Decimal Average {get;set;}
    public Decimal Min {get;set;}
    public Decimal Max {get;set;}

public List<GroupedQuery> queryResults {get;set;}

public List<sObject> queries = [Select b.Period__r.Name Name, SUM(b.Amount__c) Amount From Bud__c b group by Period__r.Name];
 {                                          
queryResults = new List<GroupedQuery>();
for (sObject query: queries)
{
    GroupedQuery myObject = new GroupedQuery();
    myObject.Count = Integer.valueOf(query.get('Amount'));
    myObject.GroupBy1 = String.valueOf(query.get('Name'));
    queryResults.Add(myObject);
}   }   }    

 

 

  • November 18, 2010
  • Like
  • 0

public class Activity 

{
Task Task;
public Activity(ApexPages.StandardController controller) 
{
    }
List<Task> tsk = new List<Task>();
public List<Task> getactivit()
    { 
     tsk = [select Subject, Assign_To__c,Status, ActivityDate, Description, Action_Item__c from Task where WhatId =:ApexPages.CurrentPage().getParameters().get('id')];
         return tsk;
     }

 

public class Activity {Task Task;public Activity(ApexPages.StandardController controller) {    }List<Task> tsk = new List<Task>();public List<Task> getactivit()    {      tsk = [select Subject, Assign_To__c,Status, ActivityDate, Description, Action_Item__c from Task where WhatId =:ApexPages.CurrentPage().getParameters().get('id')];         return tsk;    

}

}

 

-----------------------------------------------------------------------------------------------

Can anyone help me out with the test class, and should the test class be along with the above code.

 

Appreciate your help

 

I need a little help getting this to work.  I thought there were only two pieces of code to add (one to visual force page and one to the controller for the visual force page) to accept user input through a visual force page. 

 

 

 

I can initialize approvalComment in the visual force page's controller and I can enter text in the approvalComment field on the visual force page, but I only get my initialized value back...  NOT what the user types in the inputTextarea. 

 

 

 

I am trying to understand what I am missing and why. 

 

 

 

visualforce page code: 

 

<apex:form id="mainForm">  

 

.... 

 

<apex:actionRegion >  

 

 <apex:pageBlock id="approvalCommentBlock" title="Approval Comments" rendered="{!(currentApprovalStateName == 'Required')}" > 

 

      <table width="600"> 

 

         <tr>  

 

            <td width="40%"><apex:outputLabel value="Enter Approval Comments." for="approvalComment" /></td>  

 

            <td width="60%"><apex:inputTextarea cols="50" id="approvalComment" value="{!approvalComment}"/></td>  

 

         </tr>  

 

      </table> 

 

   </apex:pageBlock>   

 

</apex:actionRegion> 

 

....  

 

</apex:form> 

 

 

 

 

 

 

 

visual force page's controller code: 

 

private String approvalComment;  

 

public String getApprovalComment() {   

 

     return approvalComment;  

 

}  

 

public void setApprovalComment(String s) { 

 

     approvalComment = s;  

 

} 

 

 

 

private void initializeState() { 

 

    approvalComment = 'Approval Comments go here.'; 

 

 

 

 

 

 

 

System Log: 

 

14:36:32.924|USER_DEBUG|[300]|DEBUG|approvalComment: Approval Comments go here. 

 

I am using the <apex:messages/> tag to display messages on a visualforce page that is overriding the New button on a custom object. When the messages present their font color is black, and the message is way to the left of the page.  How do I get the messages to display in red and be centered on the page rather than left justified?

 

 

 Here is my visualforce code.

<apex:page standardController="Salesforce_Issue__c"  >

<style type="text/css">
.exceptionText{font-style:italic;
font-size:16px;
font-weight:bold;
text-align:center;
color:red;}
</style>


<apex:form>
<apex:pageBlock mode="edit">
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!Save}"/>
<apex:commandButton value="Cancel" action="{!Cancel}"/>
</apex:pageBlockButtons>

<apex:messages layout="table" styleClass="exceptionText"/>

 It seems that the css is not working fully. Font-weight,  font-size, font-style all work but text-align and color don't seem to be recognized.

 

 

Any help would be appreciated.

 

Hi There!

 

I have a need to update a date field on an opportunity when the task status is changed to completed.Workflow as follows:

 

Task marked "Completed" > Field "Follow up date" = TODAY() + 5

 

Pretty simple, but I will be using this trigger as framework for other triggers to get all our reps in line to follow through with a process, so it's pretty important. Thanks anyone who's willing to help.

 

 

hi I have a custom controller to test....I have written the test method for this  controller...please find below the part of a code which has an error...

 

I cannot capture the ContactId from userinfo1....since i logged in as a system admin...

 

To explain further, I capture the contact record Id from the user record created on the portal...I even used ....

 

Profile p = [select Id from profile where Name = 'Portal User'];

User userInfo1 = [Select ContactId, Id,lastname,ProfileId from User where ProfileId =: P.Id];

 

But I dont see the record of mine, when i log into the portal , i see some other record.....So How can i solve...this...or....how can I use the userinfo.getuserId in the test method.....I am stuck here...Please help !!!!!

 

User userInfo1 = [Select ContactId, Id from User where Id =: userInfo.getUserId()];
        contact = [Select Id,firstName,lastName,Anticipated_Term_Start_Date_

_c,Email,Program_of_Interest__c,HomePhone,MobilePhone,Birthdate,
        Contact_Status__c,Gender__c,OtherPhone,LeadSource,MailingStreet,MailingCity,MailingCountry,MailingPostalCode,MailingState,
        OtherStreet,OtherCity,OtherCountry, OtherPostalCode,OtherState,What_are_you_applying_to__c from Contact where Id =: userInfo1.ContactId];

 

Thank you all....

I'm only getting 14% coverage on the custom controller.  The controller basically lists fields that contain formula values onto a Visualforce page.  If a check box is checked on a record, the field will display on the Visualforce page.

 

Below is the error message which highlights the code that isn't covered in red, but I'm not sure how to go about writing test code to cover them. 

 

Thanks in advance to anyone that can help,

 

Here's a link to the image:

http://www.flickr.com

 

 

 

 

 

Guys:

 

I am very very green when it comes to Apex Classes/Triggers. I have developed the following code in my sandbox and tested it out and it works when I do tests on the objects:

 

 

trigger FiberQualification on GPON_Address__c (after insert, after update) {
list<Household_Address__c> gpon = [select id,name, fiber_video_eligible__c, property_owner__c, fiber_internet_eligible__c, complex_location__c from Household_Address__c where name=:Trigger.new[0].name];
if(gpon.size()>0)
{
gpon[0].fiber_video_eligible__c = Trigger.new[0].fiber_video_eligible__c;
gpon[0].fiber_internet_eligible__c = Trigger.new[0].fiber_internet_eligible__c;
gpon[0].complex_location__c = Trigger.new[0].complex_location1__c;
gpon[0].property_owner__c = Trigger.new[0].property_owner1__c;
update gpon;
}
}

 

trigger FiberQualification on GPON_Address__c (after insert, after update)

{list<Household_Address__c> gpon = [select id,name, fiber_video_eligible__c, property_owner__c, fiber_internet_eligible__c, complex_location__c from Household_Address__c where name=:Trigger.new[0].name];


if(gpon.size()>0)

{

gpon[0].fiber_video_eligible__c = Trigger.new[0].fiber_video_eligible__c;

gpon[0].fiber_internet_eligible__c = Trigger.new[0].fiber_internet_eligible__c;

gpon[0].complex_location__c = Trigger.new[0].complex_location1__c;

gpon[0].property_owner__c = Trigger.new[0].property_owner1__c;


update gpon;
}}

 

The code works great when I play around with the objects and does what I need it to do. Now I just need to get it into the Production Org. I was told to use Force.com IDE, which I am in, but now it seems I have to write a test class for this to get to 75% and I admit I have no idea how to do so.

 

If someone can use the above code and give me a very brief explanation on what code to add to meet the test requirements and to deploy I would appreciate it.

 

I have tried reading the tutorials but have thus far had no luck.

 

Thanks

Hi , I am writing a standard controller for the contact record and below is code and test method....

 

public class ContactController {
public  Contact contact {get; set;}
public string applicationId;
public Student_Information__c studentinfo{get;set;}
    public ContactController(ApexPages.StandardController controller)
    {
        contact = new contact();
        contact.LastName = userInfo.getLastName();
        contact.FirstName = userInfo.getFirstName();
 //       String ContactId = userInfo.getContactId();

// How do I test this part from here....
        User userInfo1 = [Select ContactId, Id from User where Id =: userInfo.getUserId()];
        contact = [Select Id,firstName,lastName,Anticipated_Term_Start_Date__c,Email,Program_of_Interest__c,HomePhone,MobilePhone,Birthdate,
        Contact_Status__c,Gender__c,OtherPhone,LeadSource,MailingStreet,MailingCity,MailingCountry,MailingPostalCode,MailingState,
        OtherStreet,OtherCity,OtherCountry, OtherPostalCode,OtherState,What_are_you_applying_to__c from Contact where Id =: userInfo1.ContactId];
        
        Enrollment_Opportunity__c App = [Select id from Enrollment_Opportunity__c where Applicant__c =: Contact.Id limit 1];
        this.applicationId = App.id;
    }
     
    

  /*  public ContactController()
    {
    Id id = ApexPages.currentPage().getParameters().get('id');
    contact = (id == null) ? new Contact() :
    [SELECT id,name,phone FROM Contact WHERE id = :id];
    }*/
    
    public string getapplicationId ()
    {
        return this.applicationId;
    }    
    
    public PageReference Back()
    {
    
         upsert(contact);
 
         PageReference P = new PageReference('/apex/personalinfo?Id='+Contact.Id);
         p.setRedirect(true);
      return p;
      
   }
   
    
    public PageReference SaveNext()
    {
    
     //try
    // {
         upsert(contact);
  //       contact.LastName = userInfo.getLastName();
  //      contact.FirstName = userInfo.getFirstName();
  //       User userInfo1 = [Select ContactId, Id from User where Id =: userInfo.getUserId()];
  //      contact = [Select Id,firstName,lastName,Anticipated_Term_Start_Date__c,Email,Program_of_Interest__c,HomePhone,MobilePhone,Birthdate,
  //      Contact_Status__c,Gender__c,OtherPhone,LeadSource,MailingStreet,MailingCity,MailingCountry,MailingPostalCode,MailingState,
   //     OtherStreet,OtherCity,OtherCountry, OtherPostalCode,OtherState,What_are_you_applying_to__c from Contact where Id =: userInfo1.ContactId];
         PageReference P = new PageReference('/apex/campacademy?Id='+Contact.Id);
         p.setRedirect(true);
    // }
    // catch(System.DMLException e)
    // {
    //     ApexPages.addMessages(e);
    //  
      //}    
      
      return p;
      
   }
   public PageReference Next()
    {
    
     //try
    // {
         update(contact);
    //     User userInfo1 = [Select ContactId, Id from User where Id =: userInfo.getUserId()];
   //     contact = [Select Id,firstName,lastName,Anticipated_Term_Start_Date__c,Email,Program_of_Interest__c,HomePhone,MobilePhone,Birthdate,
   //     Contact_Status__c,Gender__c,OtherPhone,LeadSource,MailingStreet,MailingCity,MailingCountry,MailingPostalCode,MailingState,
  //     OtherStreet,OtherCity,OtherCountry, OtherPostalCode,OtherState,What_are_you_applying_to__c from Contact where Id =: userInfo1.ContactId];
         if(contact.What_are_you_applying_to__c=='Interlochen Summer Arts Camp'){
         PageReference p = new PageReference('/apex/NewCampApp?Id='+contact.id);
         p.setRedirect(true);
         return p;
         }
         else{        
         PageReference p = new PageReference('/apex/NewApplication?Id='+contact.id);
         p.setRedirect(true);
         return p;
      }
    }  

 /*  
    public PageReference Exit()
    {
    
     //try
    // {
         upsert(contact);
     
         PageReference P = new PageReference('/apex/NewCampApp?Id='+Contact.Id);
         p.setRedirect(true);
    // }
    // catch(System.DMLException e)
    // {
    //     ApexPages.addMessages(e);
    //  
      //}    
      
      return p;
      
   }
  */
     public PageReference SaveExit()
    {
    
     //try
    // {
         upsert(contact);
         PageReference P = new PageReference('/apex/customerportal');
    // }
    // catch(System.DMLException e)
    // {
    //     ApexPages.addMessages(e);
    //  
      //}    
      
      return p;
      
   }
   public PageReference submit()
    {
    
     //try
    // {
         update(contact);
         studentinfo=[Select Id from Student_Information__c where Contact__c =: Contact.Id];
         PageReference r = new PageReference('https://c.cs0.visual.force.com/apex/personalinfo1?Id='+Studentinfo.Id);
    // }
    // catch(System.DMLException e)
    // {
    //     ApexPages.addMessages(e);
    //  
      //}    
      
      return r;
      
   }
   public PageReference Camp()
    {
    
     
         update(contact);
         PageReference r = new PageReference('https://c.cs0.visual.force.com/apex/NewCampApp?Id='+contact.id);
         r.setRedirect(true);
      return r;
      
   }
   public PageReference Academy()
    {
    
         update(contact);
         PageReference r = new PageReference('https://c.cs0.visual.force.com/apex/NewApplication?Id='+contact.Id);
         r.setRedirect(true);
      
      return r;
      
   }

 

 

 

and the test method for this...is

 

@isTest
private class TestContactController {

    static testMethod void testmyController() {
        // TO DO: implement unit test
    /*    
        Map<String,ID> profiles = new Map<String,ID>();
          List<Profile> ps = [select id, name from Profile where name =
             'Standard User1' or name = 'System Administrator'];
    
          for(Profile p : ps){
             profiles.put(p.name, p.id);
          }
        */
        
        Profile p = [select id,name from profile where name='Standard User1'];
             User u = new User(alias = 'standt', email='standarduser1@testorg.com',
                emailencodingkey='UTF-8', lastname='Test1', languagelocalekey='en_US',
                localesidkey='en_US', profileid = p.Id,
                timezonesidkey='America/Los_Angeles', username='standarduser1@testorg.com');
        insert u ;
        
        contact C =New Contact (firstName=userinfo.getFirstName(),lastName=userinfo.getlastname(),id=userinfo.getUserId());
        insert C;
        
        
        Enrollment_Opportunity__c en = New Enrollment_Opportunity__c(Applicant__c =C.Id);
        insert en;
        ApexPages.currentPage().getParameters().put('id',en.Id);
        
        Enrollment_Opportunity__c en1=New Enrollment_Opportunity__c(Applicant__c=C.Id,RecordTypeId='012T00000004cfY');
        insert en1;
        ApexPages.currentPage().getParameters().put('id',en1.Id);
       
        Enrollment_Opportunity__c en2=New Enrollment_Opportunity__c(Applicant__c=C.Id,RecordTypeId='012T00000004cfd');
        insert en2;
        ApexPages.currentPage().getParameters().put('id',en2.Id);
        
       //  ApexPages.StandardSetController ssc = new ApexPages.StandardSetController(accountList);
       // ApexPages.StandardController co=new ApexPages.StandardController(C);
        
        ContactController co = new ContactController(new ApexPages.StandardController(C));
               
        co.getapplicationId();
        co.back();
        co.SaveNext();
        co.Next();
        co.SaveExit();
        co.Submit();
        co.Camp();
        co.Academy();
        
    }
}

 

I am not able to test the user record.......I am receiving an error as LIST HAS NO ROWS FOR ASSIGNMENT TO SOBJECT...at the profile query....

 

what to do...where am I going wrong...

 

I am trying to write a trigger that will error if an account already has 2 related records from a custom object (Entity Account). Users are only allowed to create the related records through the related list on the account page. I am wondering what a trigger that would limit the number of records that can be created would look like. Any suggestions would greatly be appreciated.

 

Thanks in advance!

Hi All,

      According to the code below,  i can display the open cases in dashboard belonging only to Babara Levy, but i need the cases to be displayed according to the user when he/she logs into sfdc, for example if i login then i should see my cases in dashboard, and if other users logs into sfdc then they should be able to see their own cases in dashboard, can anyone plz help me with what are the changes to be done in class,iam need to sfdc.

 

VF PAGE:

 

<apex:page controller="retrieveCase" tabStyle="Case">
<apex:pageBlock>
{!contactName}'s Cases
<apex:pageBlockTable value="{!cases}" var="c">

<apex:column value="{!c.status}"/>
<apex:column value="{!c.subject}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>

 

CLASS:

 

public class retrieveCase {
public String getContactName() {
return 'Babara Levy';
}
public List<Case> getCases() {
return [SELECT status, subject FROM Case
WHERE Contact.name = 'Babara Levy' AND status != 'Closed' limit 5];
}
}

 

 

Thx in Advance!

Hi,

 

Beased on first radio button selection, i am showing the list of options and based on the option selected I am getting the contacts associated to the records from the controller. When i first select the result is coming as expected, whe I select another option from the list it is not giving the expected list.

 

Here is my visulaforce page code :

 

<apex:page standardController="Bugs__c" tabStyle="Bugs__c" extensions="emailCustomerswhenbugisfixed" action="{!init}">
    <apex:pageMessages ></apex:pageMessages>
    <apex:form >
        <apex:pageBlock title="Email to Customers" > 
           <apex:pageBlockSection columns="2">
               <apex:outputText value="Bug fixed in:"/>         
               <apex:selectRadio value="{!fixOption}">
                   <apex:selectOptions value="{!FixedOptions}"/>
                    <apex:actionSupport action="{!showOptions}" event="onclick"/>
               </apex:selectRadio><br/>
               <apex:outputPanel rendered="{!showSPOptions}">                    
                        <apex:outputText value="SP Fixed"/> &nbsp; &nbsp; &nbsp; &nbsp;
                        <apex:selectList value="{!SpFixed}" size="1">                          
                            <apex:selectOptions value="{!SpOptions}"/>
                            <apex:actionSupport action="{!showSPList}" event="onchange" reRender="out"/>                           
                        </apex:selectList> 
                           </apex:outputPanel>
                             <apex:outputPanel rendered="{!showVersionOptions}">
                  
                        <apex:outputText value="Version Fixed" /> &nbsp; &nbsp; &nbsp; &nbsp;
                      <apex:selectList value="{!VersionFixed}" size="1" >
                             <apex:selectOptions value="{!VersionOptions}"/> 
                       <apex:actionSupport action="{!showVersionList}" event="onchange" reRender="out1"/>                        
                        </apex:selectList>
                                 </apex:outputPanel>
           </apex:pageBlockSection>        
        </apex:pageBlock>  
                 
         <apex:outputPanel id="out">
   <apex:outputpanel style="display:block;width:100%;" rendered="{!showContactsSP}">
              <apex:pageBlock >
                    <apex:pageBlockButtons location="top">
                        <apex:commandButton value="Send Email" action="{!sendEmailSP}"/>
                    </apex:pageBlockButtons>
                    <apex:pageBlockSection title="List of Contacts">     
                          <apex:pageBlockTable value="{!ContactsSP}" var="c" width="100%">
                                <apex:column value="{!c.Name}"/>
                                <apex:column value="{!c.Email}"/>
                                <apex:column value="{!c.Account.Name}"/>
                          </apex:pageBlockTable>                   
                    </apex:pageBlockSection>
             </apex:pageBlock>
  </apex:outputpanel>
      </apex:outputPanel>

      <apex:outputPanel id="out1">
     
        <apex:outputpanel style="display:block;width:100%;" rendered="{!showContactsVersion}">
              <apex:pageBlock >
                    <apex:pageBlockButtons location="top">
                        <apex:commandButton value="Send Email" action="{!sendEmailVersion}"/>
                    </apex:pageBlockButtons>
                    <apex:pageBlockSection title="List of Contacts">     
                          <apex:pageBlockTable value="{!ContactsVersion}" var="c" width="100%">
                                <apex:column value="{!c.Name}"/>
                                <apex:column value="{!c.Email}"/>
                                <apex:column value="{!c.Account.Name}"/>
                          </apex:pageBlockTable>                   
                    </apex:pageBlockSection>
             </apex:pageBlock>
   </apex:outputpanel>
       </apex:outputPanel> 
    </apex:form>
</apex:page>

 Here is my controller:

 

public class emailCustomerswhenbugisfixed{
    
    public String fixOption {get;set;}
    public Boolean showSPOptions {get;set;}
    public Boolean showVersionOptions {get;set;}
    public String VersionFixed {get;set;}
    public String SPFixed {get;set;}
    public List<String> emailListSP = new List<String>();
    public List<String> emailListVersion = new List<String>();
    public List<Contact> conSP{get;set;} 
    public List<Contact> conVersion{get;set;} 
    public boolean showContactsSP {get;set;}
    public boolean showContactsVersion {get;set;}
    
    public emailCustomerswhenbugisfixed(ApexPages.StandardController controller) {
        showSPOptions=false;
        showVersionOptions=false;
        VersionFixed='';
        SPFixed='';
        showContactsSP=false;
        showContactsVersion=false;
    }
    
        public List<SelectOption> getSpOptions(){
        List<SelectOption> option = new List<SelectOption>();
        option.add(new selectoption('Select','Select'));
        option.add(new selectoption('10.0 SP2','10.0 SP2'));
        option.add(new selectoption('10.0 SP1','10.0 SP1'));
        option.add(new selectoption('9.3.1 SP2','9.3.1 SP2'));
        option.add(new selectoption('9.3.1 SP1','9.3.1 SP1'));
        option.add(new selectoption('9.3 SP1','9.3 SP1'));
        option.add(new selectoption('9.2 SP6','9.2 SP6'));
        option.add(new selectoption('9.2 SP5','9.2 SP5'));
        option.add(new selectoption('9.2 SP4','9.2 SP4'));
        return option;    
    }
        
    public List<SelectOption> getVersionOptions(){
        List<SelectOption> option = new List<SelectOption>();
        option.add(new selectoption('Select','Select'));
        option.add(new selectoption('10','10'));
        option.add(new selectoption('9.3.1','9.3.1'));
        option.add(new selectoption('9.3','9.3'));
        option.add(new selectoption('9.2','9.2'));
        option.add(new selectoption('9.1','9.1'));
        option.add(new selectoption('9','9'));
        option.add(new selectoption('8.3','8.3'));
        return option;    
    }
    
    public void showOptions(){
        if(fixOption=='Service Pack'){
            showSPOptions=true;
            showVersionOptions=false;
        }
        if(fixOption=='Version'){
            showVersionOptions=true;
            showSPOptions=false;
        }
    }
    
    public void ShowVersionList(){
        showContactsSP=false;
        showContactsVersion =true;
    }
    
    public void ShowSPList(){
        showContactsSP=true;
        showContactsVersion =false;
    }
    
        
    public List<Contact> getContactsSP(){
        Set<string> proNames = new Set<String>();
                List<BugCase_Association__c> bugs = [Select Id,Bug__c,Case__c,Case__r.ContactId,Bug__r.Name,Bug__r.SP_Fixed__c from bugcase_association__c 

where Bug__r.SP_Fixed__c=:SpFixed];
                for(BugCase_Association__c b : bugs){
                if(proNames.contains(b.Case__r.ContactId)){                                       
                      system.debug('DUP PRESENT');                
                  }                   
                  else {                      
                   proNames.add(b.Case__r.ContactId);                     
                   system.debug('DUP NOT PRESENT');                    
                   emailListSP.add(b.Case__r.ContactId);         
                 } 
               } 
               System.debug(emailListSP);
               conSP = [Select Id,Name,Email,AccountId,Account.Name from COntact where Id IN :emailListSP];
               System.debug(conSp);
               return conSP;
       }
      
     public List<Contact> getContactsVersion(){
              Set<string> proNames1 = new Set<String>();
                List<BugCase_Association__c> bugs = [Select Id,Bug__c,Case__c,Case__r.ContactId,Bug__r.Name,Bug__r.Version_Fixed__c from 
               bugcase_association__c where Bug__r.Version_Fixed__c=:VersionFixed];
                for(BugCase_Association__c b : bugs){
                  if(proNames1.contains(b.Case__r.ContactId)){                                       
                      system.debug('DUP PRESENT');                
                  }                   
                  else {                      
                   proNames1.add(b.Case__r.ContactId);                     
                   system.debug('DUP NOT PRESENT');                     
                   emailListVersion.add(b.Case__r.ContactId); 
                  }                  
                }
                System.debug(emailListVersion);
                conVersion = [Select Id,Name,Email,AccountId,Account.Name from COntact where Id IN :emailListVersion]; 
                System.debug(conVersion);
                return conVersion;
    }
    

    Public List<SelectOption> getFixedOptions(){
        List<SelectOption> option = new List<SelectOption>();
        option.add(new selectoption('Service Pack','Service Pack'));
        option.add(new selectoption('Version','Version'));
        return option;
    }

    public PageReference init(){
        Profile p = [select Id,Name from profile where Id=:userinfo.getProfileId()];
        if(p.Name!='UAG Manager'){
             PageReference pageRef = new PageReference('https://cs3.salesforce.com/a0J?fcf=00BQ0000000vfiK');
             pageRef.setRedirect(true);
             return pageRef;
        }
        return null;
    }
    
      public PageReference sendEmailSP(){
        try{           
            if(!emailListSP.isEmpty()){
                Messaging.MassEmailMessage mail = new Messaging.MassEmailMessage();
                mail.setTemplateId('00XQ0000000IFYF');
                mail.setSenderDisplayName('Esri Support');
                mail.setTargetObjectIds(emailListSP);
                //mail.setWhatIds(spBugs);
                Messaging.sendEmail(new Messaging.Massemailmessage[] {mail});
                PageReference pageRef = new PageReference('https://cs3.salesforce.com/a0J?fcf=00BQ0000000vfiK');
                pageRef.setRedirect(true);
                return pageRef;
            }
            else{
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info,'Could not find the bugs listed in this fix'));
                return null;
            }
        }
        catch(Exception e){
           ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,e.getMessage()));
           return null;
        }
    }
    
    public PageReference sendEmailVersion(){
        try{           
            if(!emailListVersion.isEmpty()){
                Messaging.MassEmailMessage mail = new Messaging.MassEmailMessage();
                mail.setTemplateId('00XQ0000000IFcH');
                mail.setSenderDisplayName('Esri Support');
                mail.setTargetObjectIds(emailListVersion);
                //mail.setWhatIds(versionBugs);
                Messaging.sendEmail(new Messaging.Massemailmessage[] {mail});
                PageReference pageRef = new PageReference('https://cs3.salesforce.com/a0J?fcf=00BQ0000000vfiK');
                pageRef.setRedirect(true);
                return pageRef;
            }
            else{
                ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info,'Could not find the bugs listed in this fix'));
                return null;
            }
        }
        catch(Exception e){
           ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,e.getMessage()));
           return null;
        }
    }
}

 Could anyone help me with this

 

Thanks in advance.

 

  • August 30, 2011
  • Like
  • 0

Hi,

 

I have three fields of type pickiest -  type (values -  v1,v2),product (p1,p2,p4), technology (t1,t2,t3,t4,t4)

 

I have a field dependency between product and technology. My requirement is based on the type selected the products and their corresponding technology values should change in the drop downs of product and technology.

 

My scenarios are: for v1 we can have p1,p2 and p1  can have t1,t4

                                 for v2 we can have p1,p2,p3 and p1 can have t1,t4

 

So the main problem is based on the type selection the products should change and the technologies should change based on the product.

 

Both v1 and v2 could have same products and underneath same products technology might change.

 

Could anyone suggest me how we can implement this.

 

Thanks in advance.

 

 

 

  • August 19, 2011
  • Like
  • 0

Hi,

 

I have a requirement, where our site users must be able to subscribe to the custom object's records and they should receive emails whenever the status of that record changes. They should be able to unsubscribe to the records, not to recieve any emails wheneve there is update to that record.

 

Could any one help me with this.

 

Thanks in advance.

 

  • August 02, 2011
  • Like
  • 0

Hi,

 

I overrided case view button with a visualforce page. When I created  a service cloud console app, and opened a case record, it displays External Page. Is there a way to rename the page with the case number.

 

Thanks in advance.

 

  • June 10, 2011
  • Like
  • 0

Hi,

 

I have given permission to a custom profile to send mass emails to regarding cases. When I logged in as the user of that profile, I was able to see "Mass Email Cases" unser tools on the cases tab. But when I created service cloud console app, & included cases tab when i click on cases tab i don't see tools and reports on that cases tab. Is there a possibility to add tools on that page.

 

Any ideas would be og great help.

 

Thanks in advance.

 

 

  • June 10, 2011
  • Like
  • 0

Hi,

Is there a way to dynamically create sharing rules based on some predefined rules. like giving access to records dynamically using apex triggers/controller.

 

Thanks in advance.

  • June 03, 2011
  • Like
  • 0

Hi,

 

I have created a custom service cloud console app. I do not see an option to include Home tab to the service cloud console. Could any one tell me if we need to do some settings in order to include home tab to our service cloud console app.

  • May 25, 2011
  • Like
  • 0

Hi,

 

We have a requirement where in we have to have 2 tier model for our support. I am trying to implement tiered deploy model in salesforce. We have different queues based on different products. So under Tier I we will be having Sever TierI queue and Desktop Tier I, etc.....

 

Can anyone tell me how to implement this in salesforce. I don't see a way to implement this as we cannot have a queue within a queue.

 

 

 

  • May 23, 2011
  • Like
  • 0

Hi,

 

I am getting a strange error when I am trying to display the colums in a datatable:

 

<apex:dataTable value="{!EmailAttachments}" var="ar

 <apex:dataTable value="{!EmailAttachments}" var="attach" columns="2" rendered="{!(attachments!=NULL)}" width="80%">
                <apex:column value="{!attach.Name}" headerValue="File Name" width="55px;"> 
                </apex:column>
                              <apex:column headerValue="Action" width="60px;">
                    <apex:commandLink Value="View" action="{!URLFOR($Action.Attachment.Download,attach.Id)}" target="_blank">
                        <apex:param name="attachment" value="{!attach.Id}" assignTo="{!attachmentId}"/>
                    </apex:commandLink>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;
                    <apex:commandLink value="Remove" action="{!removeEmailAttachment}">                        
                        <apex:param name="attachment" value="{!attach.Id}" assignTo="{!emailaId}"/>
                    </apex:commandLink>
                </apex:column> 
            </apex:dataTable>  

 

 

and the controller method is:

 

 

  public List<Attachment> getEmailAttachments() {        
         //List<Attachment> attachment = 
         return [select Id, Name , BodyLength, CreatedById from Attachment where ParentId = :ApexPages.currentPage().getParameters().get('id') and Id in :emailattachId];        
         //return attachment;    
     }        
     
     public PageReference removeEmailAttachment(){        
         try{
             Attachment attach = [select Id, Name from attachment where id=:emailaId and ParentId = :ApexPages.currentPage().getParameters().get('id')];        
             delete attach;  
             return null;
         }catch(Exception e){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,e.getMessage()));
            return null;  
         }         
     } 

 

I am getting this strange error since two days. Is this a bug? Can anyone help me with this issue.

 

 

  • May 23, 2011
  • Like
  • 0

Hi,

 

My SOSL query on Case object not searching in all the fields except CaseNumber and Subject; I have few custom fields and formula fileds that I am using in case object.

 

Below is my code to return the search results. Could anyone please help me with this issue.

 

 

public List<Case> getCasesMPU(){
   if(CasesMPU==null){
     String escapedSearchTermParam = '*'+ApexPages.currentPage().getParameters().get('searchTerm')+'*';
   List<List<SObject>> searchList = [FIND :escapedSearchTermParam IN ALL FIELDS RETURNING Case (Id) LIMIT 200];
          List<Case> cases = ((List<case>) searchList[0]);
          casesMPU = [select Id,Subject,CaseNumber, Resolution__c,AccountId, Status, Priority,DesktopProduct__c, Created__c,Modified__c,Submitted_By__c,CreatedDate,SystemProfileVersion__c,System_profile__r.Name,System_profile__r.Version__c,System_Profile__r.Id from Case where Id in :cases and (status='open' or status='closed' or status='escalated') order by Id desc];
      }
      return CasesMPU;
  }

Even it is not searching in status and priority fileds also.

 

Thanks in advance.

  • May 18, 2011
  • Like
  • 0

Hi,

 

I am trying to send email regarding case from customer portal. I created a visualforce page that will open the email form when the user clicks on send an email link, in that page i am also giving them option to attach email with their emails.

 

Here is the visualforce page code:

 

 

<apex:page standardController="Case" extensions="NewIncidentDetailController">
<apex:form >                   
 <apex:outputPanel id="sendEmail">                    

      <apex:outputText value="Additional To" />
      <apex:inputTextArea value="{!additionalTo}"  />                                                                                                                      <apex:inputTextArea value="{!ccAddress}" />

                                                                       <apex:inputTextarea value="{!bccAddress}" />

<apex:inputText value="{!subject}" />
<apex:inputTextArea value="{!body}" richText="true"  />                       
  
                <apex:commandButton value="Send" action="{!send}"/>
                <apex:commandButton value="Attach File" action="{!eAttach}" />
                <apex:commandButton value="Cancel" action="{!cancel}"/><br/><br/>
                <apex:outputPanel title="Accompanying File" id="emailAttach">
                <b style="font-size:12px;font-family:Verdana;">1.Select the File</b><br/><br/>
            <font style="font-size:12px;font-family:Verdana;">Click the browse button to find the file</font><br/><br/>
            <apex:inputFile value="{!emailfilebody}" fileName="{!emailfileName}" ></apex:inputFile><br/><br/>
             <b style="font-size:12px;font-family:Verdana">2. Click the "Attach File" button.</b><br/><br/>
            <font style="font-size:12px;font-family:Verdana">Repeat steps 1 and 2 to attach multiple files.</font><br/><br/>
            <apex:commandButton action="{!emailAttach}" value="Attach" styleClass="attachbutton"/><br/><br/>
            <b style="font-size:12px;font-family:Verdana">3.Click the Done button to complete the upload process. </b><br/><br/>
            <font style="font-size:12px;font-family:Verdana">( This will cancel an in-progress upload.)</font><br/><br/>
            <apex:commandButton value="Done" action="{!done}" styleClass="donebutton"/><br/>
            </apex:outputPanel>
                 </apex:outputPanel>
            </div>
                </td>
                </tr>
                </table>
    </apex:form>
</apex:page>

 

Here is my controller:

 

 

public with sharing class NewIncidentDetailController {
 
public Transient String emailfileName {get;set;}
    public Transient Blob emailfileBody {get;set;} 
 public Transient List<Messaging.Emailfileattachment> efa  new List<Messaging.Emailfileattachment>();

  public PageReference send(){
          try{
              Case incident = [Select Id,Contact.Email,Subject,ContactId,OwnerId,Con_Email__c,Owner.Email,Owner.Name,CaseNumber,Thread_id__c from Case where Id=:ApexPages.currentPage().getParameters().get('id')];
              String[] toAddress = new String[] {};
              String[] CcAddresses = new String[] {};
              String[] addBccAddress = new String[] {};
              String caseSubject;
              Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
              if(additionalto!=NULL && additionalto!=''){
                  String addTo = additionalto;
                  String[] addToAddresses = addTo.split(';');
                  addToAddresses.add('sravanthi.esri@gmail.com');
                  toAddress = addToAddresses;
                  mail.setToAddresses(toAddress);
              }
              else{
                  toAddress = new String[] {'sravanthi.esri@gmail.com'};
                  mail.setToAddresses(toAddress);
              }
              if(ccAddress!=NULL && ccAddress!=''){
                  String ccAdd = ccAddress;
                  String[] ccAddress = ccAdd.split(';');
                  CcAddresses = ccAddress;
                  mail.setCcAddresses(CcAddresses);                  
              }
              if(bccAddress!=NULL && bccAddress!=''){
                  String addBcc = bccAddress;
                  addBccAddress = addBcc.split(';');
                  mail.setBccAddresses(addBccAddress);                                    
              }
              if(Subject!=NULL && Subject!=''){
                  caseSubject = Subject+' '+incident.Thread_id__c;
              }
              else{
                  caseSubject = incident.Subject+' '+incident.Thread_id__c;
              }
              mail.setSubject(caseSubject);
              mail.setHtmlBody(Body);
              mail.setWhatId(incident.Id);
              /*Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
              if(!emailAttachments.isEmpty()){
                 List<document> doc = [Select Id,Name,Body from document where Id in :emailAttachments];
                 for(document a : doc){
                     efa.setFileName(a.Name);
                     efa.setBody(a.Body);    
                 }
                 mail.setFileAttachments(new Messaging.EmailFileAttachment[] {efa} );
              }*/
              if(!efa.isEmpty())
                  mail.setFileAttachments(efa);
              Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
              PageReference pageRef = new PageReference('/apex/IncidentDetailsPage?id='+ApexPages.CurrentPage().getParameters().get('id'));
              pageRef.setRedirect(true);
              return pageRef;
          }catch(Exception e){
              ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,e.getMessage()));
              return null;    
          }
     }  


   public PageReference emailAttach(){
         if(emailfileName!=NULL && emailfileBody!=NULL){
             Messaging.Emailfileattachment emailAttach = new Messaging.Emailfileattachment();
             emailAttach.setFileName(emailfileName);
             emailAttach.setBody(emailfileBody);
             efa.add(emailAttach);
         }
         return null;
     } 
}

 

 

Can anyone please help me with this isuue.

Thanks in advance

 

  • May 16, 2011
  • Like
  • 0

Hi,

 

I have seconadry contact email on my case. So when any email is sent out from within Salesforce (using "Send an Email" button), the secondary contact email must also be included in the email. I wrote a trigger on EmailMessage object to update the CcAddress with the secondary contact email address. It is inserting the email address in the to filed but is not send email to secondary conatct. Here is my code.

 

 

trigger SeconadryConInfoOnEmails on EmailMessage (before insert,before update) {
    Set<Id> parentCase = new Set<Id>();
    Map<id,Case> mapCase = new Map<Id,Case>();
    for(EmailMessage t : Trigger.New){
        parentcase.add(t.ParentId);
    }    
    List<Case> lstCase = [select Id,Sec_Contact__c,Con_Email__c,Con_Phone__c from Case where Id in :parentCase];
    for(case c: lstCase){
        mapCase.put(c.Id,c);
    }
    for(EmailMessage m :  Trigger.New){
        if(mapCase.containskey(m.ParentId)){
            if(mapCase.get(m.ParentId).Con_Email__c!=NULL){
                if(m.CcAddress ==NULL){
                    m.CcAddress = mapCase.get(m.ParentId).Con_Email__c;

                }
                else{
                    m.CcAddress = m.CcAddress+';'+mapCase.get(m.ParentId).Con_Email__c;
                } 
            }
        }
    }
}

 

 

 

Can anyone help me to solev my issue.

Thanks in advance.

  • May 11, 2011
  • Like
  • 0

Hi,

When a portal user is adding a comment to a case it is not triggering an email to the case owner. So what i tried to do is to create an emailmessage record so that it can be tracked in the Emails related list of a case. But when i am trying to insert the Email Message as a portal user it is giving me the following error:

 

Insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: []

 

 

The following is the code that I am using.

 

 

 Case incident = [Select Id,Contact.Email,ContactId,OwnerId,Owner.Email,Owner.Name,CaseNumber from Case where Id='500Q0000003JYzUIAW'];
               CaseComment comment = new CaseComment();
               String reason = '<b>Number of people affected by this issue:</b>3<br/><b>Here is the business Justification:</b><br/>';
               comment.CommentBody = reason;
               comment.ParentId = '500Q0000003JYzUIAW';
               insert comment;
EmailMessage m = new EmailMessage();
               m.ParentId ='500Q0000003JYzUIAW';
               m.HtmlBody = 'Hi&nbsp;'+incident.Owner.Name+','+'<br/><u>Request to Escalate incident</u><br/><br/>'+comment.CommentBody;   
               m.Subject = 'A new comment has been added to the incident# '+incident.CaseNumber;
               m.ToAddress=incident.Owner.Email;
               m.FromAddress=incident.Contact.Email;
               m.Status='0';
               insert m;
System.debug(m);

 

 

Can portal users create emailMessages or not?

 

I tried to send an email to the owner but that is not linked to the case.

 

Any ideas how to achieve this.

 

Thanks in advance.

  • May 04, 2011
  • Like
  • 0

Hi,

Using the below post I was able to sort the dataTable but I am not able to implement the pagination. If I am using the standardsetcontroller, it is throwing an error. Did anyone implement pagination as well after sorting the dataTable. If yes, could you please share your code or give some ideas how to implement pagination along with sorting.

 

http://boards.developerforce.com/t5/Visualforce-Development/How-To-Sort-Tables/m-p/122987

 

Thanks in advance.

  • April 22, 2011
  • Like
  • 0

Hi,

 

I am trying to get the list of  records from a custom object. I am having a input checkbox in the last column of the datatable. When anyone selects the checkbox, I am using a actionsupport component to send the Id of that record to the controller and perform. The id value is not passed to the controller. I am getting an error, Attempt to de-reference a null object.

 

The requirement is I have to display the sessions based on the dates. Users can register to the sessions by selecting the check boxes and click on register button. When they click register, he must be registered for all the selected sessions. 

 

Could anyone help me with this issue

 

Here is my Visualforce Page

 

 

<apex:page controller="sessionRegisterController">
<apex:form >
<apex:outputPanel >
<apex:selectRadio value="{!sessionDate}">
<apex:selectOptions value="{!SessionDates}" >
</apex:selectOptions>
<apex:actionSupport action="{!refreshsessionList}" event="onchange"/>
</apex:selectRadio>
</apex:outPutPanel>
<apex:outputPanel >
<apex:dataTable value="{!Sessions}" var="s">
<apex:column headerValue="Session Name" value="{!s.Session_Name__c}"/>
<apex:column headerValue="Presenters" value="{!s.Session_Name__c}"/>
<apex:column headerValue="Time" value="{!s.Session_Name__c}"/>
<apex:column headerValue="Location" value="{!s.Session_Name__c}"/>
<apex:column headerValue="Register">
<apex:inputCheckbox value="{!sessionChecked}">
<apex:inputHidden value="{!s.Id}"/>
<apex:actionSupport event="onclick" action="{!selectedSessions}">
<apex:param name="sessionId" value="{!s.Id}" assignTo="{!sessionId}"/>
</apex:actionSupport>
</apex:inputCheckbox>
</apex:column>
</apex:dataTable>
<apex:commandButton value="Register" action="{!Registration}"/>
</apex:outputPanel>
</apex:form>
</apex:page>

 

 

Here is my Controller

 

public with sharing class sessionRegisterController{

public String sessionDate{get;set;}
public Apexpages.StandardSetController con {get;set;}
public Boolean sessionChecked {get;set;}
public Id sessionId {get;set;}
public List<Id> selectedList {get;set;}

public sessionRegisterController(){
Sessions__c defaultDate = [select Id, Session_Date__c from Sessions__c order by Session_Date__c asc limit 1];
sessionDate = defaultDate.Session_Date__c;
refreshsessionList();
sessionChecked = false;
}

public void selectedSessions(){
if(sessionChecked==true)
selectedList.add(sessionId);
}


public List<SelectOption> getSessionDates(){
List<SelectOption> options = new List<SelectOption>();
List<Sessions__c> sessionList = [select Id, Session_Date__c from Sessions__c order by Session_Date__c asc];
Set<String> sessionSet = new Set<String>();
for(Sessions__c session: sessionList){
if(sessionSet.contains(session.Session_Date__c)){
}
else{
sessionSet.add(session.Session_Date__c);
options.add(new selectOption(session.Session_Date__c,session.Session_Date__c));
}
}
return options;
}

public void refreshsessionList(){
con = new ApexPages.StandardSetController(Database.getQueryLocator([Select Id,Session_Name__c, Presenters__c,Session_Time__c,Session_Location__c from Sessions__c where Session_Date__c=:sessionDate]));
con.setPageSize(10);
}

public void next(){
con.next();
}

public void previous(){
con.previous();
}

public Boolean getHasNext(){
return con.getHasNext();
}

public Boolean getHasPrevious(){
return con.getHasPrevious();
}

public List<Sessions__c> getSessions(){
return con.getRecords();
}

public PageReference Registration(){
User u = [select Id, Email,ContactId, CommunityNickName from User where id = :userinfo.getUserId()];
List<Sessions__c> registerList = [Select Id from Sessions__c where Id in :selectedList];
for(Sessions__c session : registerList){
Attendees_Registrations__c register = new Attendees_Registrations__c();
register.Sessions__c =session.Id;
register.Contact__c = u.ContactId;
register.AttendeeEmail__c = u.Email;
register.AttendeeEcas__c = u.CommunityNickname;
register.User__c = u.Id;
insert register;
}
return null;
}

}

Thanks, in advance

  • April 20, 2011
  • Like
  • 0

Hi,

 

I am trying to display the cases based on option selected by the user. I have two options open incidents and closed incidents. By default it will display open incidents. when user selects closed incidents it should display all the closed incidents. I somehow managed to build this. But the pagination is not working properly. For the datatable to refresh I have seen in other posts, that we should not use if(con==null) --  this will not refresh the table. I have commented that part. The moment I have commented that line in my controller, pagination is not working. Could anyhelp me with this issue. Below is my visaluforce page and the controller :

 

 

<apex:page sidebar="false" controller="MyIncidentsPageController">

<script>
var val;
function changeCaseType(changedvalue){
val = changedvalue.value;
setCaseStatusMethod(val);
}
</script>
<apex:form >
<apex:outputPanel >
<apex:selectRadio value="{!caseType}" onchange="changeCaseType(this)">
<apex:selectOptions value="{!items}">
</apex:selectOptions>
</apex:selectRadio>
</apex:outputPanel>
<apex:actionFunction action="{!setCaseStatusMethod}" name="setCaseStatusMethod">
</apex:actionFunction>
<apex:outputPanel style="padding:10px;display:block;" id="caseList">
<apex:dataTable value="{!Cases}" var="OI" headerClass="header" style="border-style:solid;border-width:2px;border-color:#c8c8c8;" rowClasses="odd,even" width="100%">
<apex:column headerValue="Incident" style="padding:10px;">
<apex:outputText >{!OI.CaseNumber}</apex:outputText>
</apex:column>
<apex:column value="{!OI.Created__c}" headerValue="Created" style="padding:10px;color:#2f627f;"/>
<apex:column value="{!OI.Modified__c}" headerValue="Modified" style="padding:10px;color:#2f627f;"/>
<apex:column value="{!OI.Priority}" headerValue="Priority" style="padding:10px;color:#2f627f;"/>
<apex:column value="{!OI.Productweb__c}" headerValue="Product" style="padding:10px;color:#2f627f;"/>
<apex:column value="{!OI.Submitted_By__c}" headerValue="Submitted By" style="padding:10px;color:#2f627f;"/>
<apex:column value="{!OI.Subject}" headerValue="Subject" style="padding:10px;color:#2f627f;"/>
<apex:column value="{!OI.Status}" headerValue="Status" style="padding:10px;color:#2f627f;"/>
</apex:dataTable>
<apex:panelGrid columns="3" style="float:right;" id="links">
<apex:commandLink action="{!previous}" rendered="{!hasPrevious}" style="padding:12px;">Previous</apex:commandlink>
<apex:outputLabel rendered="{!(hasPrevious && hasNext)}" >|</apex:outputLabel>
<apex:commandLink action="{!next}" rendered="{!hasNext}" style="padding:12px;">Next</apex:commandlink>
</apex:panelGrid><br/>
</apex:outputPanel>
<apex:outputpanel style="float:right;display:block;margin-right:7px;padding-top:2px;">

</apex:outputPanel>
</apex:form>
</apex:page>

 

 

Here is my controller

 

 

public with sharing class MyIncidentsPageController {

public List<Case> caseList {get;set;}
String caseType;
public String caseStatus {get;set;}

public String getcaseType(){
return caseType;
}

public void setcaseType(String caseType){
this.caseType = caseType;
}

public PageReference setCaseStatusMethod(){
caseStatus = caseType;
return null;
}

public MyIncidentsPageController(){
caseType='Open';
caseStatus='Open';
}

public List<SelectOption> getItems(){
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('Open','Open Incidents'));
options.add(new SelectOption('Closed','Closed Incidents'));
return options;
}

public ApexPages.StandardSetController con{
get{
// if(con==null){
con = new ApexPages.StandardSetController(Database.getQueryLocator([select Id,Subject,CaseNumber, Resolution__c,AccountId, Status, Priority,Productweb__c, Created__c,Modified__c,Submitted_By__c,CreatedDate from Case where status=:caseStatus order by CreatedDate desc]));
con.setPageSize(10);
// }
return con;
}
set;
}

public Boolean hasNext{
get{
return con.getHasNext();
}
set;
}

public Boolean hasPrevious {
get{
return con.getHasPrevious();
}
set;
}

public void next(){
con.next();
}

public void previous(){
con.previous();
}

public List<Case> getCases(){
caseList = con.getRecords();
return caseList;
}

}

 

 

 

Thanks in advance.

  • April 13, 2011
  • Like
  • 0

Hi,

 

I am trying to display the cases based on option selected by the user. I have two options open incidents and closed incidents. By default it will display open incidents. when user selects closed incidents it should display all the closed incidents. I somehow managed to build this. But the pagination is not working properly. For the datatable to refresh I have seen in other posts, that we should not use if(con==null) --  this will not refresh the table. I have commented that part. The moment I have commented that line in my controller, pagination is not working. Could anyhelp me with this issue. Below is my visaluforce page and the controller :

 

 

<apex:page sidebar="false" controller="MyIncidentsPageController">

<script>
    var val;
    function changeCaseType(changedvalue){
        val = changedvalue.value;
        setCaseStatusMethod(val);
    }
</script>
<apex:form >
    <apex:outputPanel >
       <apex:selectRadio value="{!caseType}" onchange="changeCaseType(this)">
           <apex:selectOptions value="{!items}">
           </apex:selectOptions>           
       </apex:selectRadio> 
    </apex:outputPanel>
    <apex:actionFunction action="{!setCaseStatusMethod}" name="setCaseStatusMethod">
    </apex:actionFunction> 
    <apex:outputPanel style="padding:10px;display:block;" id="caseList">
    <apex:dataTable value="{!Cases}" var="OI"  headerClass="header" style="border-style:solid;border-width:2px;border-color:#c8c8c8;" rowClasses="odd,even" width="100%">
        <apex:column headerValue="Incident" style="padding:10px;">  
                <apex:outputText >{!OI.CaseNumber}</apex:outputText>
        </apex:column>
        <apex:column value="{!OI.Created__c}" headerValue="Created" style="padding:10px;color:#2f627f;"/>
        <apex:column value="{!OI.Modified__c}" headerValue="Modified" style="padding:10px;color:#2f627f;"/>
        <apex:column value="{!OI.Priority}" headerValue="Priority" style="padding:10px;color:#2f627f;"/>
        <apex:column value="{!OI.Productweb__c}" headerValue="Product" style="padding:10px;color:#2f627f;"/>
        <apex:column value="{!OI.Submitted_By__c}" headerValue="Submitted By" style="padding:10px;color:#2f627f;"/>
        <apex:column value="{!OI.Subject}" headerValue="Subject" style="padding:10px;color:#2f627f;"/>
        <apex:column value="{!OI.Status}" headerValue="Status" style="padding:10px;color:#2f627f;"/>
    </apex:dataTable>
     <apex:panelGrid columns="3" style="float:right;" id="links">
    <apex:commandLink action="{!previous}" rendered="{!hasPrevious}" style="padding:12px;">Previous</apex:commandlink>
    <apex:outputLabel rendered="{!(hasPrevious && hasNext)}" >|</apex:outputLabel>
    <apex:commandLink action="{!next}" rendered="{!hasNext}" style="padding:12px;">Next</apex:commandlink>
    </apex:panelGrid><br/>
    </apex:outputPanel>
    <apex:outputpanel style="float:right;display:block;margin-right:7px;padding-top:2px;">

    </apex:outputPanel>
       </apex:form>
</apex:page>

 

 

Here is my controller

 

 

public with sharing class MyIncidentsPageController {
           
    public List<Case> caseList {get;set;}
    String caseType;    
    public String caseStatus {get;set;}
    
    public String getcaseType(){
        return caseType;
    } 
    
    public void setcaseType(String caseType){
        this.caseType = caseType;
    }
    
    public PageReference setCaseStatusMethod(){
        caseStatus = caseType;
        return null;
    }
       
    public MyIncidentsPageController(){
        caseType='Open';
        caseStatus='Open';
    }
    
    public List<SelectOption> getItems(){
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('Open','Open Incidents'));
        options.add(new SelectOption('Closed','Closed Incidents'));
        return options;
    }

    public ApexPages.StandardSetController con{
        get{
         // if(con==null){
                con = new ApexPages.StandardSetController(Database.getQueryLocator([select Id,Subject,CaseNumber, Resolution__c,AccountId, Status, Priority,Productweb__c, Created__c,Modified__c,Submitted_By__c,CreatedDate from Case where status=:caseStatus order by CreatedDate desc]));
                con.setPageSize(10);
          //  }
          return con;
        }
        set;
    }
    
    public Boolean hasNext{
        get{
            return con.getHasNext();
        }
        set;
    }
    
    public Boolean hasPrevious {
        get{
            return con.getHasPrevious();
        }
        set;
    }
    
    public void next(){
        con.next();
    }

    public void previous(){
        con.previous();
    }
    
    public List<Case> getCases(){
        caseList = con.getRecords();
        return caseList;    
    }

}

 

 

 

Thanks in advance.

  • April 13, 2011
  • Like
  • 0

Hi,

 

I have a requirement where i need to get the total number of votes that the logged in user has voted. There is a field Called votetotal on ideas object but, it is giving both positive and negative points. I want to get the number of votes whether it might be positive or negative.

 

Does any one has any idea how to query this as Vote is a child object of idea it is not allowing me to use count on vote object

  • March 14, 2011
  • Like
  • 0

Hi,

 

I am trying to get the number of ideas by status for th elogged in user. But i am getting the following error:

 

Error: Compile Error: unexpected token: 'where' at line 13 column 78

 public List<AggregateResult> IdeasSubmitted = new List<AggregateResult>();

IdeasUnderConsideration = [select count(id) from Idea group by status where CreatedById = '00530000003Xem5'];

 

 

Can anyone help me with this.

 

Thanks in advance

  • March 14, 2011
  • Like
  • 0

I have two different components that search for the same object. In the first search when i enter the keyword, the same value is assigned to the second search component. I am doing this by passing the first search parameter to the second search component. The code for first search is as follows:

 

<apex:component controller="ProductSearchController">
    <apex:form >
    <table border="0">
      <tr>
       <td valign="top">
        <apex:inputText value="{!searchParam}" id="search" size="21" style="border-color:#2C6892;border-style:solid;border-width:1px;height:18px;"/> </td>
       <td >
        <apex:commandButton style="background:url({!$Resource.ProductSearch}) no-repeat;width:20px;height:21px;margin:0px;margin-bottom:0px;margin-left:-4px;" action="{!SearchResults}"/>
       </td>
      </tr>
     </table>
      <p>  <apex:inputCheckbox value="{!Solutions}" title="Solutions" selected="true" style="margin-left:0px;"/>Solutions
        <apex:inputCheckbox value="{!Partners}" title="Partners" style="margin-left:20px;margin-bottom:0px;"/>Partners
      </p>
    </apex:form>
</apex:component>

 

The visualforce page for second earch is :

 

<apex:component controller="ProductSearchController">
<apex:attribute name="value" type="string" assignTo="{!SearchKeyword}" description="Search Keyword"/>
    <apex:form >
         <table border="0">
       <tr>
        <td valign="top">
        <apex:inputText value="{!SearchKeyword}" id="searchKey" size="68" style="border-color:#2C6892;border-style:solid;border-width:1px;height:18px;" /> </td>
        <td>
        <apex:commandButton style="background:url({!$Resource.ProductSearch}) no-repeat;width:20px;height:21px;margin:0px;margin-top:0px;margin-left:-4px;" action="{!SearchResultsKey}"/> </td>
        </tr>
        </table>
        <table border="0">
         <tr>
         <td valign="top">
        <apex:inputCheckbox value="{!Certified}"/>Certified&nbsp;&nbsp;&nbsp;
        <apex:inputCheckbox value="{!All}"/>All&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;
        <apex:inputCheckbox value="{!Solutions}"/>Solutions&nbsp;&nbsp;&nbsp;
        <apex:inputCheckbox value="{!Partners}"/>Partners </td></tr></table>
    </apex:form>
</apex:component>

 

My issue is when i give a parameter to the first component, i am able to display the same value in the second component's search box. But when I enter a new parameter in the second component, it is not taking the new value. It is still taking the old value. The attribute value is not overwritten.

 

Any suggestions????

 

Here is my controller

 

 

 

 

Thanks in advance.

  • March 02, 2011
  • Like
  • 0

Hi,

 

I have a requirement, where our site users must be able to subscribe to the custom object's records and they should receive emails whenever the status of that record changes. They should be able to unsubscribe to the records, not to recieve any emails wheneve there is update to that record.

 

Could any one help me with this.

 

Thanks in advance.

 

  • August 02, 2011
  • Like
  • 0

Hi All,

 

I have created a custom button on the opportunity object which  I need to autopopulate some certain fields.

 

All is working however I am really struggling to insert close date (which we want to autopopulate with today). 

 

 

Please any ponters would be helpful

 

Regards

  • July 14, 2011
  • Like
  • 0

In fact, struggling with a lot...this is like the eleventeenth post I've made on this page and controller...it just keeps getting bigger. Anyway, here is the situation.  I have a datatable that I want to allow users to filter with two different picklists, which are called Unit and Principle. The datatables are reRendered based on dynamic soql queries generated by what they select from the filter picklists, and the constructor is set up so that the page defaults to be filtered to only record's in the User's Unit and All Principles. The user has to select the combination of Unit and Principle that they want and then click a Filter button to get a different view.  I actually have all that working.

 

The part that I am struggling with is getting the two picklist values to reRender. The Unit that a User selects should change the available Principles to select from and vice versa. So I am trying to use dynamic soql for this too. There were points in my playing around with it that it kind of worked...it would work up until the first time I clicked the filter button, but then anytime after it just pulled all values, and now it's just pulling all Values, and I can't get back to the partial success I was having. I'm pretty lost and tired at this point, so I am just going to throw the code out there to see if any of you has any ideas or opinions.  Thanks!

 

BTW, I am not going to post the entire controller or page because they are getting pretty long. 

 

public with sharing class narrativeWizard_Controller {
        
        public String accountID;
        public String swpnAccount { get; set; }
        public SchoolWorkPlanLog__c getLog { get; set; }
        public List<UniversalJoin__c> juncObs { get; set; }
        public List<cAIS> theWrappers { get; set; } 
        public Map<ID,List<cAIS>> theWrapperMap { get; set; }
        public List<DeployedStrategy__c> theDSs { get; set; }
        public List<Goal__c> theGoals { get; set; }
        public List<cGS> theGoalWrappers { get; set; }        
        public Set<String> unitOptions = new Set<String>();
        public String selectedUnit { get; set; }
        public Set<String> princyOptions = new Set<String>();
        public String selectedPrincy { get; set; }
        //public Set<String> catyOptions = new Set<String>();
        //public String selectedCaty { get; set; }
        public List<cCONS> theConWrappers { get; set; }
        public List<cCASES> theCaseWrappers { get; set; }
        public String unitFilter { get; set; }
        public Set<String> goalUnitOptions = new Set<String>();
        public String selectedGoalUnit { get; set; }
        
        
        //sets up class extension of SchoolWorkPlanLog__c
        private final SchoolWorkPlanLog__c swpn;
                
        //CONSTRUCTOR
        public narrativeWizard_Controller(ApexPages.StandardController swpnController) {
            this.accountID = ApexPages.currentPage().getParameters().get('aID');
            this.swpn = (SchoolWorkPlanLog__c)swpnController.getRecord();
            this.setUpAccount();  
            this.makesStrategyWrappers();
            this.makesGoalWrappers();
            this.makesContactWrappers();
            this.makesCaseWrappers(); 
            this.getLog= new SchoolWorkPlanLog__c();
            this.setUpUnitFilter();
            this.selectedUnit = setUpUnitFilter();
            this.selectedGoalUnit = setUpUnitFilter();
            this.getAllStrategyUnits();
            this.getStratyPrincys();
            this.getAllGoals();
        }
        
        //pulls the Account from which the Log was initiated.
        public void setUpAccount() {
            Account acct = [select ID, Name from Account where ID = :accountID Limit 1];
            this.swpnAccount = acct.Name;
        }
        
        //pulls the user who initiated the log so that lists can be filtered to the Unit they belong to.
        public String setUpUnitFilter() {
                ID UP = Userinfo.getUserId();
                User userX = [select ID, Name, Department__c, Unit__c from User where ID =:UP];         
                
                return userX.Unit__c;
        }
        
        //pulls all Strategies to generate inital list of Unit options.
        public void getAllStrategyUnits() {
        	
        	for(DeployedStrategy__c aDS : [select ID, Name, Principle__c, Category__c, Unit__c from DeployedStrategy__c where Account__c = :accountID And Status__c = 'Active']) {
        		unitOptions.add(aDS.Unit__c);
        	}
        }
        
        //generates query strings to pull Unit Options based on the Princple that was chosen.
        public void getStratyUnits() {
        	            
            List<DeployedStrategy__c> theDSs2= new List<DeployedStrategy__c>();
        	String queryString2;
        	
        	if(this.selectedPrincy != 'All') {
        		queryString2 = 'select ID, Name, Principle__c, Category__c, Unit__c from DeployedStrategy__c where Account__c = :accountID And Status__c = \'Active\' and Principle__c =:selectedPrincy';
        	}
        	if(this.selectedPrincy == 'All') {
        		queryString2 = 'select ID, Name, Principle__c, Category__c, Unit__c from DeployedStrategy__c where Account__c = :accountID And Status__c = \'Active\'';
        	} 
        	
        	theDSs2 = Database.query(queryString2);
        	
        	for(DeployedStrategy__c aDS : theDSs2) {
        		unitOptions.add(aDS.Unit__c);
        	}
        }
        
        public void getStratyPrincys() {
        	
        	List<DeployedStrategy__c> theDSs3= new List<DeployedStrategy__c>();
        	String queryString3;
        	
        	if(this.selectedUnit != 'All') {
        		queryString3 = 'select ID, Name, Principle__c, Category__c, Unit__c from DeployedStrategy__c where Account__c = :accountID And Status__c = \'Active\' AND Unit__c =:selectedUnit';
        	}
        	if(this.selectedUnit == 'All') {
        		queryString3 = 'select ID, Name, Principle__c, Category__c, Unit__c from DeployedStrategy__c where Account__c = :accountID And Status__c = \'Active\'';
        	}
        	        	
        	theDSs3 = Database.query(queryString3);
        	
        	for(DeployedStrategy__c aDS : theDSs3) {
        		princyOptions.add(aDS.Principle__c);
        	}
        	
        }  

 

<apex:pageBlock id="pb2">
          <apex:pageBlockSection columns="1">
              <apex:pageBlockSectionItem >
                  <apex:commandButton action="{!processSelected}" value="Save" style="left:300px;position:relative;" />
                  <apex:commandButton action="{!cancelButton}" value="Cancel" style="left:310px;position:relative;"/>
              </apex:pageBlockSectionItem>
          </apex:pageBlockSection>
      <apex:pageBlockSection title="Select the Work Plans, Goals, Cases and Contacts that this Entry pertains to." collapsible="false" rendered="{!showAIandGoal}" columns="1">
          <apex:tabPanel switchType="client" selectedTab="tab1" >
              <apex:tab label="Work Plans" id="tab1">
              <apex:pageBlockSection collapsible="false" columns="3">
              <apex:pageBlockSectionItem >
               <apex:outputLabel value="Filter by Unit"/>
               <apex:selectList value="{!selectedUnit}" size="1" id="uniList">
                  <apex:selectOptions value="{!Units}"/>
                  <apex:actionSupport event="onchange" reRender="princyList" action="{!getStratyPrincys}" status="UnitStatus" />
                  <apex:actionStatus id="UnitStatus" startText="Fetching Principles..."/>
               </apex:selectList>
              </apex:pageBlockSectionItem>          
              <apex:pageBlockSectionItem >
              <apex:outputLabel value="Filter by Principle"/>
               <apex:selectList value="{!selectedPrincy}" size="1" id="princyList">
                  <apex:selectOptions value="{!Princys}"/>
                  <apex:actionSupport event="onchange" reRender="uniList" action="{!getStratyUnits}" status="PrincyStatus"/>
                  <apex:actionStatus id="PrincyStatus" startText="Fetching Principles..."/>
               </apex:selectList>
              </apex:pageBlockSectionItem>
              <apex:pageBlockSectionItem >
                  <apex:commandButton action="{!makesStrategyWrappers}" reRender="table1" value="Filter">
                      <apex:actionSupport event="onchange" status="UnitStatus"/>
                      <apex:actionStatus id="UnitStatus" startText="Fetching Records..."/>
                  </apex:commandButton>
              </apex:pageBlockSectionItem>              

 

 

I'm playing around with css and visualforce.  I believe this could be very useful but I'm having an issue with where to place the tags.

 

I have a static resource loaded called tablayoutCSS that is a zip file with some images and css.

 

One of the images is a background image we want to use for the whole page.  Where and how do I place this in visualforce?

 

Thanks,

Hello,


I guess this question has been raised several times already but I couldn't make it working even with some example found on the Web ...

I have an APEX class containing a variable for which I need to get a value from a VF Page. Then I have another method that should return the value of this variable (nothing useful ... just an example). My class contains the following :

 


public class myClass {
    public string myVariable;
  
    public string getTheValue() {    
        return myVariable;
    }
    
    public void setMyVariable(string s) {
        myVariable = s;
    }
}

 

An my page is as follow :

<apex:page standardController="Quote" renderas="pdf">
    <html>
        <body>    
            <div style="border-width:1px; border-style:solid; position:fixed; top:450px; right:1px">
<apex:outputText value="{!theValue}">
<apex:param assignTo="{!myVariable}" value="Hello World"/>
</apex:outputText>
            </div>
        </body>
    </html>
</apex:page>

 

But I never get anything displayed in the outputText tag. I tried to put the apex:param part before the outuputText as I thought that maybe it has not been initialized ... but it didn't help.

Does anybody have an idea about what's wrong ?

Hey guys,

the following code gives me headaches:

 

<apex:pageBlockTable value="{!tasks}" var="task" id="table" style="width:100%;">
        <apex:column >
            <apex:facet name="header">Related Object</apex:facet>
            <apex:outputLink value="https://na4.salesforce.com/{!task.What.Id}">{!task.What.Name}</apex:outputLink>
        </apex:column>
...

 The link in the table column should lead directly to the detail page of the "WhatId" object of the task.

 

The funny thing is that the links show up correctly in a normal visualforce page within SFDC. But as soon as I use the page in a public site, the links won't show up... What's the problem here?

 

Thank you in advance

Aljoscha

Hi,

 

Does anyone know how to do this? I thought it would be quite straightforward. I set up two datatables and two different queries in my controller but one (the second column) just doesn't show anything.

Is there a standard approach to displaying two lists of objects in two columns in VisualForce?

 

I can post code later but not sure how much it would help because I've described what I've done.

 

Regards,

 

Ian

Have a Rich Text Field that I have set-up using InlineEditing on my VF Page.  However, when you mouse over it, the area that gets highlighted with the pencil is so narrow in height users can't tell that they have an ability to click and edit the field.  Any other field type works fine.  How do I increase the height of the highlighted area?

 

Sample code for this field is as follows:

<apex:outputField value="{!quote.Quote_Notes__c}">
<apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick" resetFunction="resetInlineEdit"/>
</apex:outputField>

 

  • July 12, 2011
  • Like
  • 0

Hi,

 

We have a requirement where in we have to have 2 tier model for our support. I am trying to implement tiered deploy model in salesforce. We have different queues based on different products. So under Tier I we will be having Sever TierI queue and Desktop Tier I, etc.....

 

Can anyone tell me how to implement this in salesforce. I don't see a way to implement this as we cannot have a queue within a queue.

 

 

 

  • May 23, 2011
  • Like
  • 0

Hi,

 

I am getting a strange error when I am trying to display the colums in a datatable:

 

<apex:dataTable value="{!EmailAttachments}" var="ar

 <apex:dataTable value="{!EmailAttachments}" var="attach" columns="2" rendered="{!(attachments!=NULL)}" width="80%">
                <apex:column value="{!attach.Name}" headerValue="File Name" width="55px;"> 
                </apex:column>
                              <apex:column headerValue="Action" width="60px;">
                    <apex:commandLink Value="View" action="{!URLFOR($Action.Attachment.Download,attach.Id)}" target="_blank">
                        <apex:param name="attachment" value="{!attach.Id}" assignTo="{!attachmentId}"/>
                    </apex:commandLink>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;
                    <apex:commandLink value="Remove" action="{!removeEmailAttachment}">                        
                        <apex:param name="attachment" value="{!attach.Id}" assignTo="{!emailaId}"/>
                    </apex:commandLink>
                </apex:column> 
            </apex:dataTable>  

 

 

and the controller method is:

 

 

  public List<Attachment> getEmailAttachments() {        
         //List<Attachment> attachment = 
         return [select Id, Name , BodyLength, CreatedById from Attachment where ParentId = :ApexPages.currentPage().getParameters().get('id') and Id in :emailattachId];        
         //return attachment;    
     }        
     
     public PageReference removeEmailAttachment(){        
         try{
             Attachment attach = [select Id, Name from attachment where id=:emailaId and ParentId = :ApexPages.currentPage().getParameters().get('id')];        
             delete attach;  
             return null;
         }catch(Exception e){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,e.getMessage()));
            return null;  
         }         
     } 

 

I am getting this strange error since two days. Is this a bug? Can anyone help me with this issue.

 

 

  • May 23, 2011
  • Like
  • 0

Hi,

 

       I  need to add a Opportunity field on Approval History related list.

        Any Help is greatly appreciated.

 

 

Thanks,

Kiran