• MellowYellow
  • NEWBIE
  • 25 Points
  • Member since 2011

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 13
    Questions
  • 17
    Replies
I am trying to create a report that contains CAse, Account and Opportunity data.  This works fine, but I am not able to include the most recent Case Comment.  The query returns the Case Commtnt, but I can't figure out how to access it from VF.  Here is my code so far;
public class retrieveCaseComments{
public List<Case> getCaseInfo() {
        return [Select CaseNumber,Owner.FirstName,Status,Subject, (Select CommentBody From CaseComments ORDER BY CreatedDate DESC LIMIT 1),  Opportunity_Name__r.StageName, Opportunity_Name__r.ExpectedRevenue,Opportunity_Name__r.CloseDate, Account.Name From Case Where Case.status != 'closed' LIMIT 50];
   // limit 50 for debug
 }  
}



<apex:page controller="retrieveCaseComments" >
    <apex:pageBlock title="Case Report" >
        <apex:pageBlockTable value="{!CaseInfo}" var="v" >     
            <apex:column value="{!v.CaseNumber}" headervalue="Case"/>
            <apex:column value="{!v.Owner.FirstName}" headerValue="Case Owner"/>
              <apex:column value="{!v.Subject}" headervalue="Subject" />      
            <apex:column value="{!v.Status}" headervalue="Status" />
<!-- need to show most recent Case Comment here -->
            <apex:column value="{!v.Opportunity_Name__r.StageName}" headervalue="Opportunity Stage" />
            <apex:column value="{!v.Opportunity_Name__r.ExpectedRevenue}" headervalue="Expected Revenue"/>
             Opportunity_Name__r.ExpectedRevenue
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>

I'm trying to find a way to have several fields populate automatically when a new record is entered.  Most of the fields values will come from SOQL Selects.

The trigger should only execute the first time the record is created.  The records will be created from the standard 'New' button, but a custom button can also be used.

 

Thanks for any examples or links

I'm having trouble retrieving values from multiple SObjects.

I have a Custom Object which has a Master-Detail relationship to Account.  Call it Object1.  I need to retrieve values from the Account which are lookup fields to the User Object.

 

Select account__r.Name, account__r.Account_Manager From Object  >this returns the account name and the userId of the Account Manager

 

I need to retrieve the Account Manager's name and e-mail

Select account__r.Account_Manager.Name, account__r.Account_Manager.email from Object1  > doesn't return anything.

 

I can retrieve the userId for the Account_Manager, but how do I then access the User fields for that Id?

 

Thanks! 

I have a rather lengthy web form and am receiving feedback from users that they are 'getting lost' while filling it out.  I would like to find a way to add a visual aid to show them which field is selected.  Typically this is done by showing a border around the field or changing the background color.  I'm sure this can be done with JQuery, but am trying to use native SFDC as much as possible.

 Is there an easy way to ad this feature?

I'm trying to find a way to read a string into an array (<list>).  I know that I can get the string.Length and then loop through from 1 to Length, but I can't figure out how to get the character at position.loop_counter in the string.  This is for a custom apex controller.

 

Thanks!

 

 

I have a simple VF page that calls a custom controller to retrieve contacts for the account being viewed.  I would like to display a message such as "No records found" if the query returns no records.    I don't know if this should be added to the VF page or the controller.  Code is included below;

 

 


<apex:page controller="MSContactsCon3" showheader="false">
    <apex:pageBlock >
        <apex:pageBlockTable value="{!contacts}" var="o">
           <apex:column headervalue="Name" >
           <apex:outputlink value="/{!o.id}">{!o.name}</apex:outputLink>
           </apex:column>
           <apex:column value="{!o.title}"/>
           <apex:column value="{!o.phone}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>


public class MSContactsCon3 {

String accountVar = ApexPages.currentPage().getParameters().get('id');
    public ApexPages.StandardSetController setCon {
     
        get {
            if(setCon == null) {
                setCon = new ApexPages.StandardSetController(Database.getQueryLocator([SELECT  Id, Title, Phone, Name,  Contact_type__c  FROM Contact Where AccountId =  :AccountVar     AND contact_type__c INCLUDES ( 'Executive Contact') Order by lastname]));
            }
            return setCon;
        }
        set;
    }
    public List<Contact> getContacts()
 {  
         return (List<Contact>) setCon.getRecords();
    }
}

I'm trying to figure out how I can query a related object in Visualforce, without using a custom controller.  Essentially what I'm trying to do is embed a SOQL query and display the results in a VF page instead of having to use a custom controller or extension.  I have the custom controller working with the VF page, but was just wondering if there is an easier way to do this (like in ColdFusion or PHP).

 

Thanks

I am trying to create a project in Eclipse with only the items that I am modifying.  I am currently able to do this with the Deploy/Change Set feature in the Web UI.  In Eclipse I expand the objects and select the items I want to include in my project using the 'Add/Remove Metadata Components' menu item.
So far, so good.   When the items are added to my local Eclipse project, they are now XML listings of the entire object with no option to select only the fields, workflow rules, validation rules etc.  In other words, I selected sub components of an object to add to my project, but I only see the complete object in my project.

 How can I promote only the individual items from sandbox to production?  I don't want to promote the entire objects.

I am trying to add bold font formatting by using the style attribute.  I am able to set the style to italic, or the color to red, but not the font-weight;

<apex:pageBlockSectionItem >
                <apex:outputText style="font-weight:900;" value="This text should be in BOLD" />
                <apex:inputField value="{!Opportunity.Test_Field__c}"/>
</apex:pageBlockSectionItem>



I would also like to be able to insert a line-feed in the outputText if possible.

 

I  tried adding the escape="true" attribute, but wasn't able to add <B></B>  or <BR> tags that were recognized by the browser as HTML.


I'm trying to create a VF page that displays a table of Opportunity and Contract values.  I need to use an IF statement so that blank rows don't get created if the test condition is false.  I'm not able to escape the HTML tags so that the browser treats them as HTML instead of text.

Here is an example of what I'm trying to do;

<apex:page standardController="Opportunity">
   
             <table border="1" cellPadding="4">       
          <TR> <TH> Name of Fee </TH> <TH>Current Fee</TH> <TH> Updated Fee </TH> </TR>
          <TR><TD>
        {!IF((Opportunity.Contract__r.FieldA = Opportunity.FieldB),
         'Standard Fee:' & ' </TD> <TD> ' & TEXT(Opportunity.Contract__r.FieldA) &  ' </TD><TD> ' &     TEXT(Opportunity.Field)  , "" )}                                                                                
          </TD></TR>                                              
          </table>
       </apex:page>

I am trying to create a new opportunity object and populate some fields from related objects.  I am having trouble getting the value of a custom field on the Account Object.  Example;

for(Contract c:Trigger.new){

Opportunity newopp = new Opportuity(
   Sales_Rep__c    = c.Sales_Mgr__c 

// Where Sales_Mgr__c  resides in the Account object

New Opportunity.accountId is populated from contract.accountID and should provide a reference point to get the Sales_Mgr__c from Account object.

 I have tried [Select Sales_Mgr__c From Account where accountId = : newopp.accountId Limit 1]  without success

Newbie Question -
 I am trying to write a trigger which creates a new task when the Contract is saved.
In the task I need to populate the Sales_Name__c field with the value from the contract field Sales_Rep_c.
I am gettin a compile error indicating an invalid foreign key relationship for c.Sales_Rep_c;

Sales_Name__c = [SELECT Name From User Where Id = : c.Sales_Rep_c.id];


If I look at the properties of the Contract field Sales_rep_c it is a reference(custom) with foreign key Sales_rep_r
The Contract field Sales_Rep_c is populated with the correct id value for the user name.

Any help is appreciated!



I am creating a new Opportunity record with an Apex trigger.  I'm able to set the field values on the new Opportunity, except for the RecordType, which is a picklist containing 2 values.  I have the id value for the picklist value, I'm just not able to set it.

 

Thanks

I would like to be able to sync email to Salesforce.  I used to be able to do this, but now the icon is gone.  Can you help?
I am trying to create a report that contains CAse, Account and Opportunity data.  This works fine, but I am not able to include the most recent Case Comment.  The query returns the Case Commtnt, but I can't figure out how to access it from VF.  Here is my code so far;
public class retrieveCaseComments{
public List<Case> getCaseInfo() {
        return [Select CaseNumber,Owner.FirstName,Status,Subject, (Select CommentBody From CaseComments ORDER BY CreatedDate DESC LIMIT 1),  Opportunity_Name__r.StageName, Opportunity_Name__r.ExpectedRevenue,Opportunity_Name__r.CloseDate, Account.Name From Case Where Case.status != 'closed' LIMIT 50];
   // limit 50 for debug
 }  
}



<apex:page controller="retrieveCaseComments" >
    <apex:pageBlock title="Case Report" >
        <apex:pageBlockTable value="{!CaseInfo}" var="v" >     
            <apex:column value="{!v.CaseNumber}" headervalue="Case"/>
            <apex:column value="{!v.Owner.FirstName}" headerValue="Case Owner"/>
              <apex:column value="{!v.Subject}" headervalue="Subject" />      
            <apex:column value="{!v.Status}" headervalue="Status" />
<!-- need to show most recent Case Comment here -->
            <apex:column value="{!v.Opportunity_Name__r.StageName}" headervalue="Opportunity Stage" />
            <apex:column value="{!v.Opportunity_Name__r.ExpectedRevenue}" headervalue="Expected Revenue"/>
             Opportunity_Name__r.ExpectedRevenue
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>

I'm having trouble retrieving values from multiple SObjects.

I have a Custom Object which has a Master-Detail relationship to Account.  Call it Object1.  I need to retrieve values from the Account which are lookup fields to the User Object.

 

Select account__r.Name, account__r.Account_Manager From Object  >this returns the account name and the userId of the Account Manager

 

I need to retrieve the Account Manager's name and e-mail

Select account__r.Account_Manager.Name, account__r.Account_Manager.email from Object1  > doesn't return anything.

 

I can retrieve the userId for the Account_Manager, but how do I then access the User fields for that Id?

 

Thanks! 

I have a simple VF page that calls a custom controller to retrieve contacts for the account being viewed.  I would like to display a message such as "No records found" if the query returns no records.    I don't know if this should be added to the VF page or the controller.  Code is included below;

 

 


<apex:page controller="MSContactsCon3" showheader="false">
    <apex:pageBlock >
        <apex:pageBlockTable value="{!contacts}" var="o">
           <apex:column headervalue="Name" >
           <apex:outputlink value="/{!o.id}">{!o.name}</apex:outputLink>
           </apex:column>
           <apex:column value="{!o.title}"/>
           <apex:column value="{!o.phone}"/>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>


public class MSContactsCon3 {

String accountVar = ApexPages.currentPage().getParameters().get('id');
    public ApexPages.StandardSetController setCon {
     
        get {
            if(setCon == null) {
                setCon = new ApexPages.StandardSetController(Database.getQueryLocator([SELECT  Id, Title, Phone, Name,  Contact_type__c  FROM Contact Where AccountId =  :AccountVar     AND contact_type__c INCLUDES ( 'Executive Contact') Order by lastname]));
            }
            return setCon;
        }
        set;
    }
    public List<Contact> getContacts()
 {  
         return (List<Contact>) setCon.getRecords();
    }
}

I am trying to add bold font formatting by using the style attribute.  I am able to set the style to italic, or the color to red, but not the font-weight;

<apex:pageBlockSectionItem >
                <apex:outputText style="font-weight:900;" value="This text should be in BOLD" />
                <apex:inputField value="{!Opportunity.Test_Field__c}"/>
</apex:pageBlockSectionItem>



I would also like to be able to insert a line-feed in the outputText if possible.

 

I  tried adding the escape="true" attribute, but wasn't able to add <B></B>  or <BR> tags that were recognized by the browser as HTML.


I am trying to create a new opportunity object and populate some fields from related objects.  I am having trouble getting the value of a custom field on the Account Object.  Example;

for(Contract c:Trigger.new){

Opportunity newopp = new Opportuity(
   Sales_Rep__c    = c.Sales_Mgr__c 

// Where Sales_Mgr__c  resides in the Account object

New Opportunity.accountId is populated from contract.accountID and should provide a reference point to get the Sales_Mgr__c from Account object.

 I have tried [Select Sales_Mgr__c From Account where accountId = : newopp.accountId Limit 1]  without success

Newbie Question -
 I am trying to write a trigger which creates a new task when the Contract is saved.
In the task I need to populate the Sales_Name__c field with the value from the contract field Sales_Rep_c.
I am gettin a compile error indicating an invalid foreign key relationship for c.Sales_Rep_c;

Sales_Name__c = [SELECT Name From User Where Id = : c.Sales_Rep_c.id];


If I look at the properties of the Contract field Sales_rep_c it is a reference(custom) with foreign key Sales_rep_r
The Contract field Sales_Rep_c is populated with the correct id value for the user name.

Any help is appreciated!