• Bard09
  • NEWBIE
  • 50 Points
  • Member since 2008

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 27
    Replies

Hey all,

 

First time using Batch Apex to do a large bulk update.  I'm hoping to be able to run this monthly as a kind of cron job to keep a static financial field synced up each month.

 

global class MonthlyOpportunityAAV implements Database.Batchable <sObject>, Database.Stateful {

	public List <Opportunity> updateOpportunityList;

	global database.querylocator start(Database.BatchableContext BC) {
    
    	updateOpportunityList = new List <Opportunity> ();
    	
    	return Database.getQueryLocator('SELECT Id, Annualized_Value__c, Monthly_AV__c, Monthly_AV_Match__c FROM Opportunity WHERE Monthly_AV_Match__c=\'False\'');
    	
    }

    global void execute(Database.BatchableContext BC, List <sObject> scope) {

		for (sObject s : scope) {
    		
    		Opportunity o = (Opportunity)s;
    		
    		if (o.Annualized_Value__c != o.Monthly_AV__c) {
    		
	    		o.Monthly_AV__c = o.Annualized_Value__c;
	    		updateOpportunityList.add(o);
	    		
    		}
    		
    	}
    	
    	if (!updateOpportunityList.isEmpty()) {
    		
    		try {
    			update updateOpportunityList;
	    	}
	    	catch (DmlException e) {
	    		for (Integer i = 0; i < e.getNumDml(); i++) {
			    	System.debug('DMLERROR for ' + e.getDmlId(i) + ': ' + e.getDmlMessage(i));
			    }
	    	}
    		
    	}
    	

    }

}

 

I've kicked off this Batch Apex a few times, and it appears to work for a few hundred Opportunities, but then it gets hung up on a bunch of Opps that fail due to validation rules.  Here's an example of one of those rules:

 

IF(ISCHANGED(Monthly_AV__c),

FALSE,

BlahBlahBlah

)

 

As you can see, I've tried to exempt the rule from being executed if it detects an update to the Monthly AV field.  Unfortunately, this doesn't seem to be working in my code.  When I've reviewed some of the errors I get during the Batch Apex update, here's what I see.  (this is an example)

 

10:47:32.818 (186818515000)|EXCEPTION_THROWN|[33]|System.DmlException: Update failed. First exception on row 5 with id 0065000000FLPqjAAH; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, A Payment Type ID is required for this Payment Type.: [Payment_Type_Id__c]
10:47:32.989 (186989044000)|SYSTEM_METHOD_ENTRY|[36]|Exception.getNumDml()
10:47:32.989 (186989074000)|SYSTEM_METHOD_EXIT|[36]|Exception.getNumDml()
10:47:32.989 (186989103000)|SYSTEM_METHOD_ENTRY|[37]|Exception.getDmlId(Integer)
10:47:32.989 (186989130000)|SYSTEM_METHOD_EXIT|[37]|Exception.getDmlId(Integer)
10:47:32.989 (186989172000)|SYSTEM_METHOD_ENTRY|[37]|Exception.getDmlMessage(Integer)
10:47:32.989 (186989189000)|SYSTEM_METHOD_EXIT|[37]|Exception.getDmlMessage(Integer)
10:47:32.989 (186989211000)|SYSTEM_METHOD_ENTRY|[37]|System.debug(ANY)
10:47:32.989 (186989221000)|USER_DEBUG|[37]|DEBUG|DMLERROR for 0065000000FLPqjAAH: A Payment Type ID is required for this Payment Type.
10:47:32.989 (186989228000)|SYSTEM_METHOD_EXIT|[37]|System.debug(ANY)
10:47:32.989 (186989238000)|SYSTEM_METHOD_ENTRY|[36]|Exception.getNumDml()
10:47:32.989 (186989248000)|SYSTEM_METHOD_EXIT|[36]|Exception.getNumDml()
10:47:32.989 (186989259000)|SYSTEM_METHOD_ENTRY|[37]|Exception.getDmlId(Integer)
10:47:32.989 (186989270000)|SYSTEM_METHOD_EXIT|[37]|Exception.getDmlId(Integer)
10:47:32.989 (186989281000)|SYSTEM_METHOD_ENTRY|[37]|Exception.getDmlMessage(Integer)
10:47:32.989 (186989291000)|SYSTEM_METHOD_EXIT|[37]|Exception.getDmlMessage(Integer)
10:47:32.989 (186989301000)|SYSTEM_METHOD_ENTRY|[37]|System.debug(ANY)
10:47:32.989 (186989306000)|USER_DEBUG|[37]|DEBUG|DMLERROR for 0065000000FLQ0oAAH: A Payment Type ID is required for this Payment Type.

 

Can anyone help me out with what's happening here?  Am I missing something obvious?  Order of execution issue?  Exception-handling issue?

 

Kind of at a loss :\

  • January 22, 2013
  • Like
  • 0

Hey elite devs!

 

I've used wrapper classes before, but I have to say I'm absolutely stumped why I'm having problems with a wrapper class I've implemented recently for a Visualforce page.  I'd really appreciate another set of eyes on this issue.

 

The class displays a list of OpportunityContactRoles attached to an Opportunity Id in the URL, and displays them with checkboxes next to them for user-selection.

 

Stripped down class:

 

public class FulfillmentEmailController {
	
    public List <utilityContact> opportunityContactRoleList {get; set;}
    
    //Returning a list of Contact Roles related to this Opp
    public List <utilityContact> getRelevantOpportunityContactRoles() { 
        
        if (opportunityContactRoleList == null){
        	
           opportunityContactRoleList = new List <utilityContact> ();
        
           for (OpportunityContactRole eachOpportunityContactRole : [SELECT Id, ContactId, Role, Contact.Name, Contact.Email FROM OpportunityContactRole WHERE OpportunityId = :ApexPages.currentPage().getParameters().get('oppId')]){
                	
           	opportunityContactRoleList.add(new utilityContact(eachOpportunityContactRole));
                
            }
            
        }
        
        return opportunityContactRoleList;
        
    }
	
    public class utilityContact {
        
        public OpportunityContactRole oppCon {get; set;}
        public Boolean selected {get; set;}
        
        public utilityContact(OpportunityContactRole thisOpportunityContactRole) {
            oppCon = thisOpportunityContactRole;
            selected = false;
        }
        
    }

}

 

Visualforce example:

 

<apex:page controller="FulfillmentEmailController" tabStyle="Opportunity">
    <apex:form >
    	<apex:pageBlock title="Select Recipients">
            <p>Please check the contacts you would like to include.</p>
            <br />
            <apex:pageBlockTable value="{!RelevantOpportunityContactRoles}" var="c">
	            <apex:column>
	            	<apex:inputCheckbox value="{!c.selected}" />
	            </apex:column>
	            <apex:column value="{!c.oppCon.Contact.Name}"/>
	            <apex:column value="{!c.oppCon.Contact.Email}"/>
	            <apex:column value="{!c.oppCon.Role}"/>
        	</apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

I should make it clear that I've implemented code EXACTLY like this in another file-- just using different field names and such.  It works without a hitch.

 

However, when I try to run this, I get the following error:

 

     Invalid field selected for SObject Contact

     (or if I comment out the "selected" field....) Invalid field oppCon for SObject Contact

 

I've done some debugging on this, and it's clear the utility class is populating correctly.  If I change the Visualforce columns to simply {!c}, here's an example of what is displayed:

 

utilityContact:[oppCon=OpportunityContactRole:{Role=District Site Coordinator, ContactId=0035000000W0gGcAAJ, Id=00K50000009YJtFEAW}, selected=false]

 

This shows me that the wrapper class is working fine, and that it's correctly populating the fields I'm trying to query.

 

So why am I getting this error?!  Why "Contact" and not OpportunityContactRole?  Why does a different Visualforce page where I use this exact same logic (also querying OpportuntiyContactRoles) work, but this page doesn't?

 

Help me, elite devs!

  • April 28, 2012
  • Like
  • 0

I've been asked by my organization to send a notification e-mail when Opportunity Contact Roles are deleted on Closed Opportunities.

 

However, I'm 100% stymied trying to find a solution for this problem.

 

Here's what I've tried:

 

1. Apex code.  Unfortunately, OpportunityContactRole is not allowed for triggers!  So that's out.

2. Creating a Roll Up Summary field on Opportunities to roll up the total # of Contact Roles.  Unfortunately, it's not possible to roll up Contact Roles to Opportunites!

3. Creating a workflow rule.  Two problems here: first, Contact Roles aren't able to be included in Workflow rules.  Two, there is no known way to detect "isDeleted" for Workflow purposes (https://sites.secure.force.com/success/ideaView?c=09a30000000D9xtAAC&id=087300000007DvLAAU&mc=0)

 

Does anyone have any ideas-- no matter how fanciful or obtuse, that might help me implement this e-mail notification?

 

Trying to find a solution to this is driving me CRAZY!

 

  • February 23, 2011
  • Like
  • 0

Hi all,

 

Merging is a complicated beast for Salesforce, especially for a company with a lot of security management.  The Admin cannot always do record merging and so needs to delegate-- however, on the flip side, if there are hidden & data fields on each record that the merger doesn't have access to, that leads to problems when merging.  My organization is suffering from this issue as the Master Record cannot be the ONLY data that gets preserved for hidden data in a merge.

 

I figure that the best solution, apart from allowing generic Sales reps the same kind of field permisisons Admins have, is to create some kind of alternate merge page that merges records AS an Admin... effectively giving the merger view privileges on ALL fields on the record, even fields that they could not regularly see.

 

Has anyone out there implemented anything like this?

 

Just inquiring... and am willing to hear any suggestions!

 

Thanks!

  • January 18, 2011
  • Like
  • 0

Does anyone have any tips or examples for how to write test code for components with custom controllers?  I've written a few myself, but am unable to find any documentation for how to instantiate a component for test purposes.

 

If anyone could point me to an example (or, better yet, post some test code you've written yourself!) that would be amazing.

 

I'm sure this could help others as well.  Google has been absolutely useless on the topic.

  • December 09, 2010
  • Like
  • 0

In the Winter' 11 update, an Attachments section was added for Activities/Events, which was a longstanding pain point for our organization.

 

However, we use Visualforce to customize our Events page, and need to manually call each Related List.

 

However "NotesAndAttachments" doesn't work for the RelatedList name, and neither does "Attachments".

 

Does anyone know what the RelatedList name is for the Event-specific Attachments section in Visualforce?

  • November 03, 2010
  • Like
  • 0

Hey all,

 

Is there a way to display previous change data for fields on a Visualforce e-mail template, similar to Apex's trigger.old?

 

Eg "The Opportunity name has changed.  Old value: XYZ.  New Value: ABC".

 

I know I can 100% do this by coding the e-mail template in Apex-- but I really would prefer to write these sorts of e-mails with Visualforce if at all possible.

 

If anyone knows anything, it would be MUCH appreciated.

 

Thanks!

 

  • August 10, 2010
  • Like
  • 0

Our organization uses county-based designations in the United States for Territory Management, and we've managed to hack it into Salesforce for the last few years by doing the following:

 

1. Creating a custom formula field on Accounts that concatenates State & County, eg "WA-Snohomish"

2. Concatenating all 3,141 State/County combinations each year in Excel as above, matched to each of that year's territories

3. When specifying Management Rules for each territory, copy/paste as many items as above into each filter as possible, eg "WA-Snohomish,WA-King,etc"

 

This has worked for the last few years but it gets old doing so much manual data entry work to get this imported into Salesforce each year.

 

When I read about Custom Settings I immediately jumped for joy, because from what I read, it seemed like the List option would allow me to create what is effectively a static data table of these County designations, along with Territory, and directly query that for the Territory Management Rules... or at least a Formula field at the Account level.

 

Can anyone think if this would be possible?

 

Provided that it would be possible, I have another question: how would we bulk-insert the 3,141 records each year into the Custom Setting?

 

I've tried adding a Custom Setting and it appears to only work record-by-record.  There doesn't seem to be an entry in the Data Loader for bulk-inserting Custom Settings, either.

 

Anyways-- if anyone could help me with these questions, I would be very appreciative!  Thanks in advance.

  • December 09, 2009
  • Like
  • 0

Hello,

 

Our organization has Territory Management enabled, and our Sales team has requested that each Account's owner = the assigned territory's Forecast Manager.

 

Unfortunately, I'm at a loss figuring out how to query an Account's Territory in Apex.  I know Opportunities have a TerritoryId field, but Accounts don't.  Is there any way I can refer to an Account's territory in Apex code?

 

MSuggestions would be MUCH appreciated.... thanks!

  • October 05, 2009
  • Like
  • 0

I'm trying to use Visualforce to do one thing: update the owner of X events in bulk.

 

My initial attempt failed as it appears that Events don't work as either Standard Controllers or as list methods through a Custom Controller.  Ugh.

 

So I put that attempt on hold and tried something a little more basic: showing all of the Event items through an Opportunity Standard controller and allowing the user to manually edit multiple records on one page (we don't enable Inline Editing at our organization).  Here's the VF code:

 

 

<apex:page StandardController="Opportunity"> <apex:form> <apex:pageBlock title="Reassign Events" mode="edit"> <apex:pageBlockButtons> <apex:commandButton value="Save" action="{!save}"/> </apex:pageBlockButtons> <apex:pageBlockTable value="{!Opportunity.Events}" var="e"> <apex:column> <apex:inputField value="{!e.Subject}"/> </apex:column> <apex:column> <apex:inputField value="{!e.ActivityDate}"/> </apex:column> <apex:column> <apex:inputField value="{!e.OwnerId}"/> </apex:column> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>

 

 Unfortunately, when I hit "Save" the changes I make to each Event are not saved.  What am I missing here?  I tried looking to see if the recordSetVar parameter was required, but the documentation is horrible at explaining alternate use cases for that parameter.  All of their examples match the StandardController with the RecordSetVar and don't explain what it means to change it.

 

 

Anyways, if anyone knows what I need to change to get this to work, let me know.

 

Also, if anyone knows if it's possible to update Events entirely through a CustomController class without passing them to the Visualforce page, let me know as well!

 

Thanks :)

  • August 03, 2009
  • Like
  • 0

I'm doing my first major Apex scripting job to automatically create events based on a quantity # specified in Opportunity Products.  I'm not the best coder around, so please bear with me here :)

 

I'm trying to query PricebookEntry.Product2.Name but am finding that the output via Apex is the name of the field instead of the actual name specified for the related object.  This also happens with ProductCode as well.

 

For example:

 

PricebookEntry.Product.Name                             .....results in "Name"

Trigger.new[0].PricebookEntry.Product2.Name    .....results in "null"

 

I've been able to narrow down a SOQL query with other fields in the table, so I know it is possible.  Here's an example:

 

[select Id,OpportunityId,Quantity,PricebookEntry.Product2.Family from OpportunityLineItem where PricebookEntry.Product2.Family = 'Services' AND Opportunity.Id = :eachNewOpportunityLineItem.OpportunityId]

 

 

What am I missing?  Someone fill in the obvious for me :)

I only have a rudimentary knowledge of JavaScript (mostly related to basic DOM manipulation) and am not 100% certain if an S-Control would resolve the problem I'm facing in Salesforce at the moment.  But here goes....

My company recently changed territory alignments from state-by-state allocations to allocating by groups of counties.  As you can probably guess, this made creating territory rules MUCH more complicated, given that there are currently 3,141 counties in the United States.  After getting through some initial problems we were eventually successful.  (Thank goodness formula fields can be made criterion!)

However, now we are facing data validation issues with incorrect/misspelled county names.  The obvious solution would be to create a dependent picklist for counties.  However, with the limitations on picklists, it is not possible to insert all 3,141 counties in a dependent picklist.  It is also not feasible to create 50 different dependent picklists (so each state is considered) because that would seriously screw up our page layout, and require a reworking of our custom field for Counties.

The solution to me seems to be some sort of S-control that gets around the picklist limitations.  We're already using the Address Edit S-control SFDC has in the AppExchange for basic address validation.

I'm just not sure if it would be best to try to hamstring counties into that Address Edit s-control, create a new s-control for counties alone, or even if an s-control would be the best solution for this problem.

Any advice... much appreciated!  I'm trying to get an idea about where I should go with this that doesn't involve purchasing a third-party product.

Thanks!
  • October 23, 2008
  • Like
  • 0

Hey all,

 

First time using Batch Apex to do a large bulk update.  I'm hoping to be able to run this monthly as a kind of cron job to keep a static financial field synced up each month.

 

global class MonthlyOpportunityAAV implements Database.Batchable <sObject>, Database.Stateful {

	public List <Opportunity> updateOpportunityList;

	global database.querylocator start(Database.BatchableContext BC) {
    
    	updateOpportunityList = new List <Opportunity> ();
    	
    	return Database.getQueryLocator('SELECT Id, Annualized_Value__c, Monthly_AV__c, Monthly_AV_Match__c FROM Opportunity WHERE Monthly_AV_Match__c=\'False\'');
    	
    }

    global void execute(Database.BatchableContext BC, List <sObject> scope) {

		for (sObject s : scope) {
    		
    		Opportunity o = (Opportunity)s;
    		
    		if (o.Annualized_Value__c != o.Monthly_AV__c) {
    		
	    		o.Monthly_AV__c = o.Annualized_Value__c;
	    		updateOpportunityList.add(o);
	    		
    		}
    		
    	}
    	
    	if (!updateOpportunityList.isEmpty()) {
    		
    		try {
    			update updateOpportunityList;
	    	}
	    	catch (DmlException e) {
	    		for (Integer i = 0; i < e.getNumDml(); i++) {
			    	System.debug('DMLERROR for ' + e.getDmlId(i) + ': ' + e.getDmlMessage(i));
			    }
	    	}
    		
    	}
    	

    }

}

 

I've kicked off this Batch Apex a few times, and it appears to work for a few hundred Opportunities, but then it gets hung up on a bunch of Opps that fail due to validation rules.  Here's an example of one of those rules:

 

IF(ISCHANGED(Monthly_AV__c),

FALSE,

BlahBlahBlah

)

 

As you can see, I've tried to exempt the rule from being executed if it detects an update to the Monthly AV field.  Unfortunately, this doesn't seem to be working in my code.  When I've reviewed some of the errors I get during the Batch Apex update, here's what I see.  (this is an example)

 

10:47:32.818 (186818515000)|EXCEPTION_THROWN|[33]|System.DmlException: Update failed. First exception on row 5 with id 0065000000FLPqjAAH; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, A Payment Type ID is required for this Payment Type.: [Payment_Type_Id__c]
10:47:32.989 (186989044000)|SYSTEM_METHOD_ENTRY|[36]|Exception.getNumDml()
10:47:32.989 (186989074000)|SYSTEM_METHOD_EXIT|[36]|Exception.getNumDml()
10:47:32.989 (186989103000)|SYSTEM_METHOD_ENTRY|[37]|Exception.getDmlId(Integer)
10:47:32.989 (186989130000)|SYSTEM_METHOD_EXIT|[37]|Exception.getDmlId(Integer)
10:47:32.989 (186989172000)|SYSTEM_METHOD_ENTRY|[37]|Exception.getDmlMessage(Integer)
10:47:32.989 (186989189000)|SYSTEM_METHOD_EXIT|[37]|Exception.getDmlMessage(Integer)
10:47:32.989 (186989211000)|SYSTEM_METHOD_ENTRY|[37]|System.debug(ANY)
10:47:32.989 (186989221000)|USER_DEBUG|[37]|DEBUG|DMLERROR for 0065000000FLPqjAAH: A Payment Type ID is required for this Payment Type.
10:47:32.989 (186989228000)|SYSTEM_METHOD_EXIT|[37]|System.debug(ANY)
10:47:32.989 (186989238000)|SYSTEM_METHOD_ENTRY|[36]|Exception.getNumDml()
10:47:32.989 (186989248000)|SYSTEM_METHOD_EXIT|[36]|Exception.getNumDml()
10:47:32.989 (186989259000)|SYSTEM_METHOD_ENTRY|[37]|Exception.getDmlId(Integer)
10:47:32.989 (186989270000)|SYSTEM_METHOD_EXIT|[37]|Exception.getDmlId(Integer)
10:47:32.989 (186989281000)|SYSTEM_METHOD_ENTRY|[37]|Exception.getDmlMessage(Integer)
10:47:32.989 (186989291000)|SYSTEM_METHOD_EXIT|[37]|Exception.getDmlMessage(Integer)
10:47:32.989 (186989301000)|SYSTEM_METHOD_ENTRY|[37]|System.debug(ANY)
10:47:32.989 (186989306000)|USER_DEBUG|[37]|DEBUG|DMLERROR for 0065000000FLQ0oAAH: A Payment Type ID is required for this Payment Type.

 

Can anyone help me out with what's happening here?  Am I missing something obvious?  Order of execution issue?  Exception-handling issue?

 

Kind of at a loss :\

  • January 22, 2013
  • Like
  • 0

Hey elite devs!

 

I've used wrapper classes before, but I have to say I'm absolutely stumped why I'm having problems with a wrapper class I've implemented recently for a Visualforce page.  I'd really appreciate another set of eyes on this issue.

 

The class displays a list of OpportunityContactRoles attached to an Opportunity Id in the URL, and displays them with checkboxes next to them for user-selection.

 

Stripped down class:

 

public class FulfillmentEmailController {
	
    public List <utilityContact> opportunityContactRoleList {get; set;}
    
    //Returning a list of Contact Roles related to this Opp
    public List <utilityContact> getRelevantOpportunityContactRoles() { 
        
        if (opportunityContactRoleList == null){
        	
           opportunityContactRoleList = new List <utilityContact> ();
        
           for (OpportunityContactRole eachOpportunityContactRole : [SELECT Id, ContactId, Role, Contact.Name, Contact.Email FROM OpportunityContactRole WHERE OpportunityId = :ApexPages.currentPage().getParameters().get('oppId')]){
                	
           	opportunityContactRoleList.add(new utilityContact(eachOpportunityContactRole));
                
            }
            
        }
        
        return opportunityContactRoleList;
        
    }
	
    public class utilityContact {
        
        public OpportunityContactRole oppCon {get; set;}
        public Boolean selected {get; set;}
        
        public utilityContact(OpportunityContactRole thisOpportunityContactRole) {
            oppCon = thisOpportunityContactRole;
            selected = false;
        }
        
    }

}

 

Visualforce example:

 

<apex:page controller="FulfillmentEmailController" tabStyle="Opportunity">
    <apex:form >
    	<apex:pageBlock title="Select Recipients">
            <p>Please check the contacts you would like to include.</p>
            <br />
            <apex:pageBlockTable value="{!RelevantOpportunityContactRoles}" var="c">
	            <apex:column>
	            	<apex:inputCheckbox value="{!c.selected}" />
	            </apex:column>
	            <apex:column value="{!c.oppCon.Contact.Name}"/>
	            <apex:column value="{!c.oppCon.Contact.Email}"/>
	            <apex:column value="{!c.oppCon.Role}"/>
        	</apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

I should make it clear that I've implemented code EXACTLY like this in another file-- just using different field names and such.  It works without a hitch.

 

However, when I try to run this, I get the following error:

 

     Invalid field selected for SObject Contact

     (or if I comment out the "selected" field....) Invalid field oppCon for SObject Contact

 

I've done some debugging on this, and it's clear the utility class is populating correctly.  If I change the Visualforce columns to simply {!c}, here's an example of what is displayed:

 

utilityContact:[oppCon=OpportunityContactRole:{Role=District Site Coordinator, ContactId=0035000000W0gGcAAJ, Id=00K50000009YJtFEAW}, selected=false]

 

This shows me that the wrapper class is working fine, and that it's correctly populating the fields I'm trying to query.

 

So why am I getting this error?!  Why "Contact" and not OpportunityContactRole?  Why does a different Visualforce page where I use this exact same logic (also querying OpportuntiyContactRoles) work, but this page doesn't?

 

Help me, elite devs!

  • April 28, 2012
  • Like
  • 0

I've been asked by my organization to send a notification e-mail when Opportunity Contact Roles are deleted on Closed Opportunities.

 

However, I'm 100% stymied trying to find a solution for this problem.

 

Here's what I've tried:

 

1. Apex code.  Unfortunately, OpportunityContactRole is not allowed for triggers!  So that's out.

2. Creating a Roll Up Summary field on Opportunities to roll up the total # of Contact Roles.  Unfortunately, it's not possible to roll up Contact Roles to Opportunites!

3. Creating a workflow rule.  Two problems here: first, Contact Roles aren't able to be included in Workflow rules.  Two, there is no known way to detect "isDeleted" for Workflow purposes (https://sites.secure.force.com/success/ideaView?c=09a30000000D9xtAAC&id=087300000007DvLAAU&mc=0)

 

Does anyone have any ideas-- no matter how fanciful or obtuse, that might help me implement this e-mail notification?

 

Trying to find a solution to this is driving me CRAZY!

 

  • February 23, 2011
  • Like
  • 0

Does anyone have any tips or examples for how to write test code for components with custom controllers?  I've written a few myself, but am unable to find any documentation for how to instantiate a component for test purposes.

 

If anyone could point me to an example (or, better yet, post some test code you've written yourself!) that would be amazing.

 

I'm sure this could help others as well.  Google has been absolutely useless on the topic.

  • December 09, 2010
  • Like
  • 0

In the Winter' 11 update, an Attachments section was added for Activities/Events, which was a longstanding pain point for our organization.

 

However, we use Visualforce to customize our Events page, and need to manually call each Related List.

 

However "NotesAndAttachments" doesn't work for the RelatedList name, and neither does "Attachments".

 

Does anyone know what the RelatedList name is for the Event-specific Attachments section in Visualforce?

  • November 03, 2010
  • Like
  • 0

Hey all,

 

Is there a way to display previous change data for fields on a Visualforce e-mail template, similar to Apex's trigger.old?

 

Eg "The Opportunity name has changed.  Old value: XYZ.  New Value: ABC".

 

I know I can 100% do this by coding the e-mail template in Apex-- but I really would prefer to write these sorts of e-mails with Visualforce if at all possible.

 

If anyone knows anything, it would be MUCH appreciated.

 

Thanks!

 

  • August 10, 2010
  • Like
  • 0

Good day All, 

 

May i know how can i get the salesforce site URL ? say if we are in sandbox , it show : https://cs2.salesforce.com

 

if production , it show me https://na7.salesforce.com ?

 

I'm using unlimited version.

 

Thank you !

Good day, 

 

I try using following code and i get null at all ? can someone please let me know why do i miss out to get such info ?

 

 

System.debug('domain string : ' +Site.getDomain());

System.debug('getCustomWebAddress string : ' +Site.getCustomWebAddress());

System.debug('getCurrentSiteUrl String :' +Site.getCurrentSiteUrl());

System.debug('Sub domain String :' +Site.Subdomain);

System.debug('TopLevelDomain String :' +Site.TopLevelDomain);

System.debug('getOriginalUrl String :' +Site.getOriginalUrl());

 

between, i would like to get the organization instance name but is there a method to retrieve it ?

 

ie: www.mycompany.com.jp ....what i want is to get back the 'mycompany' ? how i can do that ?

 

Thank you ! 

 


Message Edited by Nakata on 03-09-2010 05:48 AM
  • March 08, 2010
  • Like
  • 0
I'm building a pricing tool and from this tool users can add products. I really don't want to reinvent the functionality of adding products that already exists. I am trying to create a button that sends the user to the out of the box add products functionality and then when completed it should return the user to the visual force page.

I am failing big time. The code below is what I have and it appears to be populating the retURL parameter correctly but this doesn't work at all. If you hit cancel in the add products tool or save it always returns you to the opp, not the visualforce page which is what I want.

Does anyone know of other URL parameters I need to add to make this work? Is it even possible?

Page:
<apex:page controller="addProductsRedirect">
<apex:outputField value="{!opp.Id}"/>-
<apex:outputField value="{!opp.Name}"/>

<apex:form >
<apex:commandLink value="Add Product" action="{!addProduct}">
<apex:param name="addProductsURL" value="{!URLFOR($Action.OpportunityLineItem.AddProduct)}" assignTo="{!addProductsURL}"/>
</apex:commandLink>
</apex:form>
{!URLFOR($Action.OpportunityLineItem.AddProduct)}
</apex:page>



Controller:
public class addProductsRedirect {

Opportunity opp;
public String addProductsURL {get; set;}

public Opportunity getOpp(){
if(opp == null){
opp = [select Id, Name from Opportunity limit 1];
}
return opp;
}

public PageReference addProduct(){
PageReference p = new PageReference(addProductsURL );
p.getParameters().put('addTo',opp.Id);
p.setRedirect(true);
return p;
}
}

Much thanks,

Jason

Message Edited by TehNrd on 12-15-2009 12:25 PM
  • December 15, 2009
  • Like
  • 0

Hi...I have written one Trigger on Territory delete ....But I am not able to cover that trigger code in my Test method . When I try to delete territory through my Apex Test class it gives me an " error : DML not allowed on Territory " .... So please let me know if there is any way to cover that code in my Test method.

Is it possible, using one of the action components like actionFunction or actionSupport, to rerender just one piece of a table? (in this case a pageBlockTable)

 

My table is listing Leads.  (Leads contained in a wrapper obj defined in the controller, to be exact.)  One of the columns contains a select control (so we've got a separate select control for each row).  When onchange fires for the select, I'd like to rerender the contents of another column in the same row.  Or it would be OK to rerender the entire other column.  But I don't want to rerender the whole table, or the whole row.

 

I don't seem to be able to do this.  If I put the column id in the rerender attribute, nothing seems to happen.  Same if I use the id of the outputPanel that's contained inside that column (which would be repeated for each row, so not sure how to refer to the outputPanel contained in a particular row.)

 

Is this possible?  Or is it only possible to refresh the table as a whole?

 

Thanks much!

  • April 08, 2009
  • Like
  • 0