• cmarz_1
  • NEWBIE
  • 25 Points
  • Member since 2009

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 13
    Questions
  • 23
    Replies

Has anyone rebuilt a standard tab in Visualforce? I am specifically looking for the Opportunities tab.

I want the tab to stay exactly the same with one small exception - I want to remove the "New" button.

I'm really not even sure where to start and thought if someone had already done this I could leverage their code.

 

Thanks!

Message Edited by cmarz_1 on 01-21-2010 11:46 AM
I just installed Chrome today and when I navigate to one of my visualforce pages it doesn't load, it just sits there "waiting for salesforce...".  If I take my user out of development mode the page loads fine.  Anyone else experiencing this issue?

I am experiancing something very strange.  I created a batch apex class, part of the query returns a custom field (Nurturing_Grade_Points__c , Formula Number field This formula references multiple objects) and the sobjects in the execute method all have that custom field set to 0.00.  Even though I know for a fact none of them are equal to zero.

 

My query is: 

Select c.Nurturing_Grade_Points__c, c.Id From CampaignMember c Where c.HasResponded = True and c.Nurturing_Grade_Points__c > 0 and c.FirstRespondedDate > 2008/1/1 and ContactID != NULL Order By c.ContactId

 

Using system.debug  in the execute method i am printing out each CampaignMember.  All of them have have Nurturing_Grade_Points__c equal to 0.00.  Example:

 

CampaignMember:{Nurturing_Grade_Points__c=0.00, Id=XXXXXXX}

 

If I go look at that capaign member I can clearly see that the Nurturing_Grade_Points__c field is set to a number higher than zero.  Something seems to be happening between the query and execute methods where my custom field is getting set to zero.  This is driving me batty anyone have any ideas why this is happening? Can you not use custom formula fields in batch apex?

Each year our Assets come up for renewal so naturally I would like to link an existing Asset with it's renewal Opportunity.  And some times multiple assets for the same account will come up for renewal together (meaning many assets need to be linked to one renewal opportunity). 

 

So I am trying to figure out a way to have a related list of existing Assets on an Opportunity.  And then (if possible) have a related list of Opportunities on Assets that will show it's original sale opportunity and all of it's subsequent renewal opportunities.  Anyone have any good ideas on how to accomplish this?  I'm stumped at the moment.

Has anyone else run into the 100KB email body limit for email services?  We have and I need to find a solution.  I'm trying to figure out a way I can truncate any email being sent to the email service via excahnge so that the email body is always under 100KB.  Although I have no clue how to do this.
I am wondering if anyone on the boards has any good ideas as to how I can approach this problem.  We want our Sales Reps to be able to send our NDA's to potential customers with just a click of a button.  I envision a custom link or button on an opportunity that when clicked could use our standard NDA (MS word format), merge in the appropriate fields (Customer Name, Address, etc) and then attach the word file to an email.  The email could be a standard Salesforce email or it could simply open up an new Outlook email (using some javascript and mailto link). In either case all the Sales rep would need to do is click send. Does this sound possible?  If so what would be my best approach to building something like this?

I'm looking to add all the emails my company sends through our excahnge server into Salesforce, if the TO email address matches an existing contact or lead record in Salesforce.  Is there anything out there that I can hook into my exchange server to accomplish this?

 

All my users have refused to use the standard salesforce Outlook integration claiming that it slows them down to much.

I'm building an edit page for Opportunity Line items.  If a users enters 2 in the QTY field and $10 in the Sell price field I'd like to total field (read only formula field) to update to $20.  Is there any method I could call to get the total to update without saving?  I want to allow the user to be able to cancel and not save their changes hence the reason for not wanting to save after the field values have been changed.

I have a command button with an action and a rerender set.  The action fills up a list and the rerender is for a pageblock that displays the list.  The pageblock's render is set to not show if the list is null (starting value).  So when the button is clicked the action should fill up the list, the rerender then should allow the pageblock to show.  Except when I run debug on the code I can see the get fuction for the list being called proir to the action of filling the list is being completed.  As a consequence the pageblock is not being displayed because it thinks the list is still null.  Accounding to the VF docs "ReRender: The ID of one or more components that are redrawn when the result of an AJAX update request returns to the client."  This doesn't seem to be the case.  Anyone have any ideas?

 

<apex:commandButton action="{!fillProductList}" value="Add Products" reRender="AddProductsTable"  status="status"  />     <apex:actionStatus id="status" startText="loading..."/>
    
<apex:pageBlock title="Add Products" id="AddProductsTable" rendered="{!NOT(ISNULL(prodList))}" >
       <apex:pageBlockTable value="{!prodList}" var="p" cellpadding="4" >
           <apex:column headerValue="Name" > {!p.Id} </apex:column>
</apex:pageBlockTable>
        </apex:pageBlock>

 

 

code

 

 

 

 

I created a custom controller as an extension to the standard Opportunity cotroller.  My visualforce page lists all of the OpportunityLineItems.  When a picklist changes it launches (actionsupport) a method in my custom controller called recalcProtex.  This method sets a number of custom fields based on the picklist selection.  The visualforce page updates the values via the rerender attruibute on my actionsupport. So the values are showing properly on the page but when I save the values are not updating in Salesforce. The OpportunityLineItems fields that my method set are equal to null (orginal value) when mySave() medthod is called.  What am I doing wrong?  The field in question is Actual_List_Price__c

 

Apex Class

 

 public class OppLineItemController {

private Opportunity opp;

public OppLineItemController(ApexPages.StandardController controller) {
this.opp = (Opportunity)controller.getRecord();
System.debug(opp.OpportunityLineItems[0].Actual_List_Price__c); // Set to null, which is correct

}

public PageReference recalcProtex( ) {
for(OpportunityLineItem oli : opp.OpportunityLineItems){
if(oli.PricebookEntry.Name == 'Protex'){
if (oli.Protex_Option__c != 'None'){
List<String> option = oli.Protex_Option__c.split(' ',-1);
System.debug(option);
// Users
oli.Users__c = option[0];
// Code Limit
oli.Code_Base_in_MB__c = option[2];
// List Price
String price= option[5].substring(1);
oli.Actual_List_Price__c = double.valueOf(price);
}
}
}
System.debug(opp.OpportunityLineItems[0].Actual_List_Price__c); // Set to proper value, e.g. not null

return null;
}

public PageReference mySave() {
System.debug(opp.OpportunityLineItems[0].Actual_List_Price__c); // Set to null again, why?

update opp.OpportunityLineItems;
PageReference oppPage = new PageReference('/' +System.currentPageReference().getParameters().get('id'));
return oppPage;
}
}

 

Visualforce Page

 

<apex:page standardController="Opportunity" extensions="OppLineItemController" tabstyle="Opportunity" >
<apex:form id="form1" >
<apex:pageBlock title="Products">
<apex:pageBlockTable value="{!Opportunity.OpportunityLineItems}" var="oli" cellpadding="4" >
<apex:column headerValue="Name" > {!oli.PricebookEntry.Name} </apex:column>
<apex:column headerValue="Option" >
<apex:inputField value="{!oli.Protex_Option__c}"> <apex:actionSupport event="onchange" action="{!recalcProtex}" rerender="ListPrice" /> </apex:inputField>
</apex:column>
<apex:column headerValue="List Price" id="ListPrice" >{!oli.Actual_List_Price__c} </apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
<apex:commandButton action="{!mySave}" value="Save Products"/>
</apex:form>
</apex:page>

 

On a lead I created a Referred By field that is a look up to another lead.  It also created a related list on a lead with a new lead button.  When a user clicks the new lead button from the related list it automatically fills in the Referred By look up with the originating lead.  This is great but I need to take it one step forward.  I need the new lead's Lead Source to be defaulted to that of the originated lead's.

So far the only way I can think of doing this is to create an Apex trigger to update the Lead Source after it's been save.  This is less than idea since I want to give the user the choice to override the lead source.  Basically I'd like to find a way to default the Lead Source Picklist on the new lead page.  This way a user will see the lead source and then make the choice to change it or not.  
I don't want my sales people entering Product Price. I want it to be calculated based on a number of custom fields I have added to the product.  I can't figure out how to turn Sell Price into a formula field.  Anyone know how to do this?
Anyone know a good way to do this?  We want to figure in the number of campaigns a lead has responded to into our lead scoring system.  Since I can't create a roll-up summary field for leads (not sure why) I'm a little baffled as to how I can accomplish this.
 

I don't think I can use a Lead Trigger (does the adding of a campaign count as a lead edit?)

I can't figure out how I could build this into a work flow.

They only thing I can think of doing is building an offline app that scans Salesforce once a night and updates a field on a lead.  I'd rather not do this if it can be avioded.

 
Anyone have any ideas?

Has anyone rebuilt a standard tab in Visualforce? I am specifically looking for the Opportunities tab.

I want the tab to stay exactly the same with one small exception - I want to remove the "New" button.

I'm really not even sure where to start and thought if someone had already done this I could leverage their code.

 

Thanks!

Message Edited by cmarz_1 on 01-21-2010 11:46 AM

I am experiancing something very strange.  I created a batch apex class, part of the query returns a custom field (Nurturing_Grade_Points__c , Formula Number field This formula references multiple objects) and the sobjects in the execute method all have that custom field set to 0.00.  Even though I know for a fact none of them are equal to zero.

 

My query is: 

Select c.Nurturing_Grade_Points__c, c.Id From CampaignMember c Where c.HasResponded = True and c.Nurturing_Grade_Points__c > 0 and c.FirstRespondedDate > 2008/1/1 and ContactID != NULL Order By c.ContactId

 

Using system.debug  in the execute method i am printing out each CampaignMember.  All of them have have Nurturing_Grade_Points__c equal to 0.00.  Example:

 

CampaignMember:{Nurturing_Grade_Points__c=0.00, Id=XXXXXXX}

 

If I go look at that capaign member I can clearly see that the Nurturing_Grade_Points__c field is set to a number higher than zero.  Something seems to be happening between the query and execute methods where my custom field is getting set to zero.  This is driving me batty anyone have any ideas why this is happening? Can you not use custom formula fields in batch apex?

I'd like to pass an Apex class that I've defined as a public inner class to a Visualforce component. When I try to save the component, I get these errors:

 

Error: Unsupported type SimpleOuter.SimpleInner[] encountered.

Error: Apex class 'simpleouter.simpleinner' does not exist.

 

Here's my sample code:

 

 

public with sharing class SimpleOuter {
public class SimpleInner {
public String one;
public String two;
}
}

<apex:component>
<apex:attribute name="phoneStatuses" type="SimpleOuter.SimpleInner[]" required="true"
description="The phone numbers and statuses to display." />
</apex:component>

 

 Any ideas?

 

  • September 18, 2009
  • Like
  • 0

Each year our Assets come up for renewal so naturally I would like to link an existing Asset with it's renewal Opportunity.  And some times multiple assets for the same account will come up for renewal together (meaning many assets need to be linked to one renewal opportunity). 

 

So I am trying to figure out a way to have a related list of existing Assets on an Opportunity.  And then (if possible) have a related list of Opportunities on Assets that will show it's original sale opportunity and all of it's subsequent renewal opportunities.  Anyone have any good ideas on how to accomplish this?  I'm stumped at the moment.

Hello,

 

I have an issue where I have conditional logic in a trigger that is based on the value of a formula field.  When running a functional test in the UI, this formula field evaluates fine and the trigger logic proceeds as expected.  When I run a testmethod with the same use case, the formula field does not evaluate and a bunch of code doesn't get covered.  

 

This is happening in two separate places in two different orgs.  I also have the debug logs to prove the formula field is getting evaluated in the functional test and not getting evaluated in the testmethod.

 

Has anyone ever run into this issue?  If so, how do you get around it without rewriting the trigger to mimic the formula field logic?

 

Thanks very much for any input!

I am wondering if anyone on the boards has any good ideas as to how I can approach this problem.  We want our Sales Reps to be able to send our NDA's to potential customers with just a click of a button.  I envision a custom link or button on an opportunity that when clicked could use our standard NDA (MS word format), merge in the appropriate fields (Customer Name, Address, etc) and then attach the word file to an email.  The email could be a standard Salesforce email or it could simply open up an new Outlook email (using some javascript and mailto link). In either case all the Sales rep would need to do is click send. Does this sound possible?  If so what would be my best approach to building something like this?

I'm looking to add all the emails my company sends through our excahnge server into Salesforce, if the TO email address matches an existing contact or lead record in Salesforce.  Is there anything out there that I can hook into my exchange server to accomplish this?

 

All my users have refused to use the standard salesforce Outlook integration claiming that it slows them down to much.

I'm building an edit page for Opportunity Line items.  If a users enters 2 in the QTY field and $10 in the Sell price field I'd like to total field (read only formula field) to update to $20.  Is there any method I could call to get the total to update without saving?  I want to allow the user to be able to cancel and not save their changes hence the reason for not wanting to save after the field values have been changed.

 

I created a custom controller as an extension to the standard Opportunity cotroller.  My visualforce page lists all of the OpportunityLineItems.  When a picklist changes it launches (actionsupport) a method in my custom controller called recalcProtex.  This method sets a number of custom fields based on the picklist selection.  The visualforce page updates the values via the rerender attruibute on my actionsupport. So the values are showing properly on the page but when I save the values are not updating in Salesforce. The OpportunityLineItems fields that my method set are equal to null (orginal value) when mySave() medthod is called.  What am I doing wrong?  The field in question is Actual_List_Price__c

 

Apex Class

 

 public class OppLineItemController {

private Opportunity opp;

public OppLineItemController(ApexPages.StandardController controller) {
this.opp = (Opportunity)controller.getRecord();
System.debug(opp.OpportunityLineItems[0].Actual_List_Price__c); // Set to null, which is correct

}

public PageReference recalcProtex( ) {
for(OpportunityLineItem oli : opp.OpportunityLineItems){
if(oli.PricebookEntry.Name == 'Protex'){
if (oli.Protex_Option__c != 'None'){
List<String> option = oli.Protex_Option__c.split(' ',-1);
System.debug(option);
// Users
oli.Users__c = option[0];
// Code Limit
oli.Code_Base_in_MB__c = option[2];
// List Price
String price= option[5].substring(1);
oli.Actual_List_Price__c = double.valueOf(price);
}
}
}
System.debug(opp.OpportunityLineItems[0].Actual_List_Price__c); // Set to proper value, e.g. not null

return null;
}

public PageReference mySave() {
System.debug(opp.OpportunityLineItems[0].Actual_List_Price__c); // Set to null again, why?

update opp.OpportunityLineItems;
PageReference oppPage = new PageReference('/' +System.currentPageReference().getParameters().get('id'));
return oppPage;
}
}

 

Visualforce Page

 

<apex:page standardController="Opportunity" extensions="OppLineItemController" tabstyle="Opportunity" >
<apex:form id="form1" >
<apex:pageBlock title="Products">
<apex:pageBlockTable value="{!Opportunity.OpportunityLineItems}" var="oli" cellpadding="4" >
<apex:column headerValue="Name" > {!oli.PricebookEntry.Name} </apex:column>
<apex:column headerValue="Option" >
<apex:inputField value="{!oli.Protex_Option__c}"> <apex:actionSupport event="onchange" action="{!recalcProtex}" rerender="ListPrice" /> </apex:inputField>
</apex:column>
<apex:column headerValue="List Price" id="ListPrice" >{!oli.Actual_List_Price__c} </apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
<apex:commandButton action="{!mySave}" value="Save Products"/>
</apex:form>
</apex:page>

 

I am running into an issue in Apex outbound email. If I have an email message that is using a template, and that I am sending to a User (via setTargetObjectId), Apex won't let me set WhatId -- if I do, it gives me this error message

"System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_ID_FIELD, WhatId is not available for sending emails to UserIds."

Is there any easy way around this limitation? Obviously via workflow rules I am able to send emails to users that have a "What" context sent (for instance, send an email to Opportunity owner when stage change X occurs). Seems like a big limitation of the Apex email service to not allow this.

For now, I am intending to set up temporary Contact objects for Users who do not have them, just so I can send them email.

Here is the code that is hitting this error. "UserId" is the ID of a User object and "WhatId" is the ID of an Opportunity.

Code:
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
EmailTemplate template = [select Id from EmailTemplate where DeveloperName = :emailTemplateUniqueName];
mail.setTemplateId(template.Id);
mail.setReplyTo('no-reply@mycompany.com');
mail.setSenderDisplayName('Salesforce');
mail.setTargetObjectId(userId);
mail.setWhatId(whatId);
mail.setSaveAsActivity(false);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
 
Any pointers much appreciated. If (as I suspect) this is just a straight Apex issue and cannot be done, I'll open an Idea to fix it.

Jeremy Kraybill
Austin, TX
Hello Everyone,

I hope you can help me on this..Im working with singleEmail to send an email to a particular sales representative on every territory. but every time I invoked my trigger via update of my objects, it returns an exception. The error is: System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_ID_FIELD, WhatId is not available for sending emails to UserIds.\.: Trigger.Notify_Rep_Trigger: line 90, column 21

my code is written below:

Account territory = [select Territory_Name__c from Account where Id =:data.Account_ID__c];
           
            if(territory.Territory_Name__c != null)
            {
               
                List<string> splitID = territory.Territory_Name__c.split(';', -1);
                Set<string> tID = new Set<string>();
                tID.clear();
               
                List<Territory> territoryId = [Select id From Territory where name in :splitID];
               
                List<UserTerritory> usersId = [Select UserId From UserTerritory where territoryid in :territoryId];
               
                for(integer x=0; x < usersId.size(); x++)
                {
                        tID.add(usersId[x].UserId);
                }
               
                List<User> emailAdd = [select Id, email from User where Id in :tID];
               
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                List <String> Addresses = new List<String>();
           
                for(integer i=0; i < emailAdd.size(); i++)
                {
                    //String[] toAddresses = new String[] {emailAdd[i].email};
       
                    //mail.setToAddresses(toAddresses);
                    mail.setCcAddresses(ccAddresses);
                   
                    mail.setBccSender(true);
                    mail.setUseSignature(false);
                    mail.setSaveAsActivity(false);
                   
                    String toTargetObjects = (string)emailAdd[i].Id;
                   
                    system.debug('target object deb:'+toTargetObjects);
                    system.debug('data id deb:'+data.Id);
                   
                    mail.setTargetObjectId(toTargetObjects);
                    mail.setWhatId(toTargetObjects);
       
                    mail.setTemplateId(templateId);
                   
                    Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
                }
            }
        }

any suggestion? I would really appreciate it if you can help me on this.


Thanks in advance,

Wilson




Message Edited by wilson34 on 11-21-2008 01:50 AM

Message Edited by wilson34 on 11-21-2008 01:51 AM

Message Edited by wilson34 on 11-21-2008 01:51 AM

Message Edited by wilson34 on 11-21-2008 01:53 AM
Hi there,
 
how is one supposed to create an "OpportunityPartner" object using the API? According to the Apex Explorer this object is only query-able and retrieve-able, so basically a readonly construction.
 
So, is creating/updating a new OpportunityPlan plain impossible is there just a trick that I'm unaware of? 
 
Cheers,
Harry
  • October 02, 2008
  • Like
  • 0
I'd like to remove the [New] button from the Opportunity tab (screen).  But I don't want to alter the Opportunity [New] functionality elsewhere.
 
How do I do this? 
  • April 18, 2008
  • Like
  • 0