-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
11Questions
-
18Replies
Fields for Customer Portal Trigger
Hello all,
Is there a specific field(s) that will identify a contact as a customer portal user? What I need to have happen is have a custom object automatically change ownership related to the contact if they are set as a portal user. Any ideas?
- chriseustace
- July 20, 2010
- Like
- 0
- Continue reading or reply
Showing a vf page on home screen
I created a VF page that I'd like to display on my homescreen.
I've tried to use iframes and an html component, it looks ok in the preview, but then is cut off when I view it on the screen, here's the code and what it looks like:
any ideas?
<br><iframe src="/apex/ParalegalBreakdown" width="50%" height="100%"></iframe></br>
- chriseustace
- July 09, 2010
- Like
- 0
- Continue reading or reply
Trigger via ContentDelivery field
Hello all,
I am trying to write a trigger that will carry over a field from the ContentDelivery table to a custom object. When I try to write the trigger, i dont see the ContentDelivery table at all. Is it not available for use in triggers at the moment?
Thanks!
Chris
- chriseustace
- June 28, 2010
- Like
- 0
- Continue reading or reply
Apex Trigger - trigger too deep problem
Hello all,
I think the reason for this issue is because I am looking to do it on both insert and update. Basically, what I need to do is have an AccountID populated into specific fields based on the Contact that is selected. Take a look at the sample below. It does work upon insert, but I get errors afterwards - I think the trigger gets caught in an infinite loop. Any help is much appreciated!
trigger AutoFill_ContactPicklists on Contact (after insert, after update) {
List<Contact> con_list = new List<Contact>();
for(Contact con : trigger.new)
{
Contact c = new Contact();
/* SOURCE */
if(con.Business_Source__c != null)
{
for(Contact c_update : [select Id,AccountId from Contact where Id =:Trigger.new[0].Id] )
{
con_list.add(new Contact(Id=Trigger.new[0].Id,Source_Account__c=c_update.AccountId));
}
}
if(con_list.size() > 0)
{
update con_list;
}
}
- chriseustace
- June 24, 2010
- Like
- 0
- Continue reading or reply
Update AccountID on Oppty when ContactId is filled out
Hello all,
I am trying to update the accountid on an oppty record where the contact has been populated, but the account is not, however I'm getting the error:
Illegal assignment from List<Contact> to Id
Here is the code:
trigger Update_Acct_Opps on Opportunity (after insert, after update) {
for(Opportunity opp : trigger.new) {
if(opp.AccountId == NULL && opp.Contact__c != NULL){
List<Opportunity> opps = new List<Opportunity>();
Opportunity oppty = new Opportunity();
oppty.AccountId = [select AccountId from Contact where Id =:Trigger.new[0].Contact__c];
opps.add(oppty);
update opps;
}
}
}
Any ideas?
Thanks!
- chriseustace
- June 21, 2010
- Like
- 0
- Continue reading or reply
Loading activities into Group Edition of SFDC
One of my new clients is running Group Edition of SFDC. I can load accounts, contacts, and leads through the UI. I tried to have salesforce enable the API to use the data loader, and they said they cannot enable it for Group Edition.
I then tried the Informatica Data Loader, and I get an error saying I am not logged into salesforce.
I have a few hundred Activities to load into salesforce, however I cannot think of any way to load them. Has anyone come across this, and if so, do you have any idea on how?
Thanks.
Chris
- chriseustace
- February 09, 2010
- Like
- 0
- Continue reading or reply
Sending Mass Email using an apex trigger
Hello all,
I am trying to write a trigger that will send out emails using a template Here is what I have. I keep getting the "location" variable undefined. I did use some code I found on this board, but am unsure what "location" is supposed to be:
Trigger Code:
trigger SendActivationEmail on Contact (after insert, after update) {
for(Contact cont : trigger.new)
{
if(cont.Send_Activation_Email__c == true)
{
string message;
string templateName = 'Thank you for joining Aprigo';
String[] toAddresses;
List<Id> idsList = getEmailAddresses(location);
EmailTemplate e = [select Id,Name,Subject,body from EmailTemplate where name like :templateName+'%'];
if(contact.Email != null)
{
Messaging.MassEmailMessage mail = new Messaging.MassEmailMessage();
mail.saveAsActivity = false;
mail.setTargetObjectIds(idsList);
mail.setTemplateId(e.Id);
mail.setUseSignature(false);
mail.setSaveAsActivity(false);
// Send the email
Messaging.sendEmail(new Messaging.MassEmailMessage[] { mail });
}
else
{
Messaging.SingleEmailMessage mail1 = new Messaging.SingleEmailMessage();
toAddresses = new String[] {'chris@eustaceconsulting.com'};
mail1.setToAddresses(toAddresses);
message = 'This email will sent to you only if Template Not Found!!!';
mail1.setHtmlBody(message);
}
}
}
}
Class Code:
public with sharing class MailerUtils
{
public static List<Id> getEmailAddresses(string groupName)
{
List<String> idList = new List<String>();
List<Id> mailToIds = new List<Id>();
Group g = [SELECT (select userOrGroupId from groupMembers) FROM group WHERE name = :groupName];
for (GroupMember gm : g.groupMembers) {
idList.add(gm.userOrGroupId);
}
User[] usr = [SELECT Id, email FROM user WHERE id IN :idList];
for(User u : usr) {
mailToIds.add(u.Id);
}
return mailToIds;
}
}
Can anyone help?
- chriseustace
- January 18, 2010
- Like
- 0
- Continue reading or reply
Apex Trigger Complete, need help deploying - testing?
I have written my first apex trigger, tested it, and it works in my sandbox. However when i try to push to production it is saying I need to run unit tests up to 75%. I am unsure on how to do this and scouring the boards has got me nowhere. Can anyone assist? My code is as follows:
trigger createSupplierMemberLink on Opportunity (after insert) {
Opportunity oppty = trigger.new[0];
if(oppty.Payroll_Type__c <> ''){
SupplierMemberLink__c sml = new SupplierMemberLink__c();
sml.RelatedProgram__c = oppty.Id;
sml.SalesDate__c = oppty.CloseDate;
sml.SalesAmount__c = oppty.Amount;
sml.Name = oppty.Name + ' Payroll';
insert sml;
}
}
- chriseustace
- December 17, 2009
- Like
- 0
- Continue reading or reply
Trigger to convert lead to account/contact/oppty
Does anyone know how I'd go about creating a trigger to convert a lead to an account contact and oppty, based upon a field in the lead? For example, A lead score of > 30, I'd like to trigger the lead to automatically convert, and kick off a notification email.
Has anyone done this before?
Thanks!
Chris
- chriseustace
- December 10, 2009
- Like
- 0
- Continue reading or reply
newbie to Apex - trying to display different info based on values
Hello all,
I am trying to develop a few visual force pages that based upon the Account State, I will redirect to different pages.
I have a basic page that allows the user to select an Account from a lookup
<apexage
controller="enerNOCController" tabStyle="Opportunity">
<apex:sectionHeader
title="New Customer Opportunity"
subtitle="Step 1 of 2"/>
<apex:includescript
value="{!$Resource.pageBlockSupplement}" />
<apex:form
>
<apexageBlock title="My
Content">
<apexageBlockButtons >
<apex:commandButton action="{!step2}" value="Next"
styleClass="btn"/>
</apexageBlockButtons>
<apexageBlockSection title="My
Content Section" columns="2">
<apex:inputField
id="accountName" value="{!opportunity.AccountId}"/>
</apexageBlockSection>
</apexageBlock>
</apex:form>
</apexage>
I also have a controller that holds some of the logic. What I am thinking is I can use if(account.State=="New York" then I'll do something
public
class enerNOCController {
Opportunity opportunity;
Account
account;
public Account getAcctName()
{
return [select
Name from Account limit 1];
}
public Account getAccount() {
if(account
== null) account = new Account();
return account;
}
public
Opportunity getOpportunity() {
if(opportunity == null) opportunity =
new Opportunity();
return opportunity;
}
public PageReference
step1() {
return Page.OpportunityDecisionTree;
}
public
PageReference step2() {
//use account.State?
if(account.State){
return
Page.opportunitydecisiontree2;
}
}
public PageReference save()
{
insert opportunity;
PageReference opptyPage = new
PageReference('/' +
opportunity.id);
opptyPage.setRedirect(true);
return
opptyPage;
}
}
Can anyone help me with this?
Thanks!
- chriseustace
- November 19, 2009
- Like
- 0
- Continue reading or reply
newbie to Apex - trying to display different info based on values
Hello all,
I am trying to develop a few visual force pages that based upon the Account State, I will redirect to different pages.
I have a basic page that allows the user to select an Account from a lookup
<apex:page controller="enerNOCController" tabStyle="Opportunity">
<apex:sectionHeader title="New Customer Opportunity"
subtitle="Step 1 of 2"/>
<apex:includescript value="{!$Resource.pageBlockSupplement}" />
<apex:form >
<apex:pageBlock title="My Content">
<apex:pageBlockButtons >
<apex:commandButton action="{!step2}" value="Next" styleClass="btn"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="My Content Section" columns="2">
<apex:inputField id="accountName" value="{!opportunity.AccountId}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
I also have a controller that holds some of the logic. What I am thinking is I can use if(account.State=="New York") then I'll do something
public class enerNOCController {
Opportunity opportunity;
Account account;
public Account getAcctName()
{
return [select Name from Account limit 1];
}
public Account getAccount() {
if(account == null) account = new Account();
return account;
}
public Opportunity getOpportunity() {
if(opportunity == null) opportunity = new Opportunity();
return opportunity;
}
public PageReference step1() {
return Page.OpportunityDecisionTree;
}
public PageReference step2() {
//use account.State?
if(account.State){
return Page.opportunitydecisiontree2;
}
}
public PageReference save() {
insert opportunity;
PageReference opptyPage = new PageReference('/' +
opportunity.id);
opptyPage.setRedirect(true);
return opptyPage;
}
}
Can anyone help me with this?
Thanks!
- chriseustace
- November 19, 2009
- Like
- 0
- Continue reading or reply
Conditional Autonumber based on Record Type
Hello all,
I checked out the forums and I can't seem to find a solution to this. On person accounts (in Enterprise Edition), I have an auto-number field but I only want increment for my "customers" record type and not my "employee" record type. Right now it is auto-numbering for both even though I want it to increment when it's the customer record type. Can someone help me with this/point me into the right direction or have some custom code that can do this?
Thanks much!
-Billy
- bhau
- July 13, 2010
- Like
- 0
- Continue reading or reply
Account Relationships - linking to a contact versus another account
Hi, I work In Force.COM for Hedge Funds
Under the Account tab, their is the "Relationship" tab where we can define any relationship with another Account and their role that they have.
Unfortunately, simply having the Account to Account relationship does not help me much considering an account may have many, many contacts within.
For example, I have a client XYZ which has a broker at Merrill lynch for example. I add the relationship to Merrill Lynch to our client, but that does not tell me which broker at ML is the key contact.
How do I force the relationship to be with a particular "Contact" instead of with an "Account"
Thanks,
M-A
- M-A
- July 13, 2010
- Like
- 0
- Continue reading or reply
custom button for email template: sending to a non-related Contact
Hello, all-
I have what I fear to be a long-shot question:
I currently have a custom button on a custom object that executes an email template. This code works; it sends the email template to a Contact that is directly related to this object via a look-up field:
location.replace('/email/author/emailauthor.jsp?retURL=/{!Custom_Object__c.Id}&p3_lkid={!Custom_Object__c.Id}&rtype=003&p2_lkid={!Custom_Object__c.VolunteerId__c }&template_id=00X50000001JKO1&p26=myemail@domain.org&p5=');
My problem is that I need a similar button that will send the same email template to a Contact in my system that is not directly related to this object via a look-up field.
I have both a cross-formula field storing my desired Contact's full name and a cross-formula field storing my desired Contact's email address. I tried putting each of those fields in my code, replacing the {!Custom_Object__c.VolunteerId__c } part, but no dice. (It looks like only ID fields work here--not custom fields.)
Is there another way?
Either 1) adding this other Contact in the "To" field, so that it would have its own button, or 2) adding this other Contact to the "CC" field, appending this other Contact to my existing button, would be equally fantastic. I have no preference.
Many thanks in advance!
- dietcola
- July 13, 2010
- Like
- 0
- Continue reading or reply
Showing a vf page on home screen
I created a VF page that I'd like to display on my homescreen.
I've tried to use iframes and an html component, it looks ok in the preview, but then is cut off when I view it on the screen, here's the code and what it looks like:
any ideas?
<br><iframe src="/apex/ParalegalBreakdown" width="50%" height="100%"></iframe></br>
- chriseustace
- July 09, 2010
- Like
- 0
- Continue reading or reply
Apex Trigger - trigger too deep problem
Hello all,
I think the reason for this issue is because I am looking to do it on both insert and update. Basically, what I need to do is have an AccountID populated into specific fields based on the Contact that is selected. Take a look at the sample below. It does work upon insert, but I get errors afterwards - I think the trigger gets caught in an infinite loop. Any help is much appreciated!
trigger AutoFill_ContactPicklists on Contact (after insert, after update) {
List<Contact> con_list = new List<Contact>();
for(Contact con : trigger.new)
{
Contact c = new Contact();
/* SOURCE */
if(con.Business_Source__c != null)
{
for(Contact c_update : [select Id,AccountId from Contact where Id =:Trigger.new[0].Id] )
{
con_list.add(new Contact(Id=Trigger.new[0].Id,Source_Account__c=c_update.AccountId));
}
}
if(con_list.size() > 0)
{
update con_list;
}
}
- chriseustace
- June 24, 2010
- Like
- 0
- Continue reading or reply
Sending Mass Email using an apex trigger
Hello all,
I am trying to write a trigger that will send out emails using a template Here is what I have. I keep getting the "location" variable undefined. I did use some code I found on this board, but am unsure what "location" is supposed to be:
Trigger Code:
trigger SendActivationEmail on Contact (after insert, after update) {
for(Contact cont : trigger.new)
{
if(cont.Send_Activation_Email__c == true)
{
string message;
string templateName = 'Thank you for joining Aprigo';
String[] toAddresses;
List<Id> idsList = getEmailAddresses(location);
EmailTemplate e = [select Id,Name,Subject,body from EmailTemplate where name like :templateName+'%'];
if(contact.Email != null)
{
Messaging.MassEmailMessage mail = new Messaging.MassEmailMessage();
mail.saveAsActivity = false;
mail.setTargetObjectIds(idsList);
mail.setTemplateId(e.Id);
mail.setUseSignature(false);
mail.setSaveAsActivity(false);
// Send the email
Messaging.sendEmail(new Messaging.MassEmailMessage[] { mail });
}
else
{
Messaging.SingleEmailMessage mail1 = new Messaging.SingleEmailMessage();
toAddresses = new String[] {'chris@eustaceconsulting.com'};
mail1.setToAddresses(toAddresses);
message = 'This email will sent to you only if Template Not Found!!!';
mail1.setHtmlBody(message);
}
}
}
}
Class Code:
public with sharing class MailerUtils
{
public static List<Id> getEmailAddresses(string groupName)
{
List<String> idList = new List<String>();
List<Id> mailToIds = new List<Id>();
Group g = [SELECT (select userOrGroupId from groupMembers) FROM group WHERE name = :groupName];
for (GroupMember gm : g.groupMembers) {
idList.add(gm.userOrGroupId);
}
User[] usr = [SELECT Id, email FROM user WHERE id IN :idList];
for(User u : usr) {
mailToIds.add(u.Id);
}
return mailToIds;
}
}
Can anyone help?
- chriseustace
- January 18, 2010
- Like
- 0
- Continue reading or reply
Trigger on User object to create another record
Hiya,
Im after some advice on what i think is going to be a pretty simple bit of code. Basically i want to write a trigger on the User object that will insert a record into a separate Staff__c object with details of the user just saved. I was unsure how to pull the details of the user just saved.
Here is some rough pseudo code! Unsure if it would even work with something along these lines? But il give it a try while waiting if anyone else has a better idea :) (updated code, works even though its rough :) )
Just need to work out how to get it to fire only once!
trigger userToStaff on User (after insert, after update) {
List<Staff__c> staffToUpdate = new List<Staff__c>();
for (User usr : Trigger.new) {
Staff__c staff = new Staff__c (
//User_ID__c = usr.Id
First_Name__c = usr.Name
);
staffToUpdate.add(staff);
}
if(staffToUpdate.size()>0){
try {
insert staffToUpdate;
} catch (exception e) {
system.debug(e.getMessage());
}
}
}
Any advice would be great!!! :)
Regards
Michael
- Brookesy--
- December 21, 2009
- Like
- 1
- Continue reading or reply
Trigger to convert lead to account/contact/oppty
Does anyone know how I'd go about creating a trigger to convert a lead to an account contact and oppty, based upon a field in the lead? For example, A lead score of > 30, I'd like to trigger the lead to automatically convert, and kick off a notification email.
Has anyone done this before?
Thanks!
Chris
- chriseustace
- December 10, 2009
- Like
- 0
- Continue reading or reply
newbie to Apex - trying to display different info based on values
Hello all,
I am trying to develop a few visual force pages that based upon the Account State, I will redirect to different pages.
I have a basic page that allows the user to select an Account from a lookup
<apexage
controller="enerNOCController" tabStyle="Opportunity">
<apex:sectionHeader
title="New Customer Opportunity"
subtitle="Step 1 of 2"/>
<apex:includescript
value="{!$Resource.pageBlockSupplement}" />
<apex:form
>
<apexageBlock title="My
Content">
<apexageBlockButtons >
<apex:commandButton action="{!step2}" value="Next"
styleClass="btn"/>
</apexageBlockButtons>
<apexageBlockSection title="My
Content Section" columns="2">
<apex:inputField
id="accountName" value="{!opportunity.AccountId}"/>
</apexageBlockSection>
</apexageBlock>
</apex:form>
</apexage>
I also have a controller that holds some of the logic. What I am thinking is I can use if(account.State=="New York" then I'll do something
public
class enerNOCController {
Opportunity opportunity;
Account
account;
public Account getAcctName()
{
return [select
Name from Account limit 1];
}
public Account getAccount() {
if(account
== null) account = new Account();
return account;
}
public
Opportunity getOpportunity() {
if(opportunity == null) opportunity =
new Opportunity();
return opportunity;
}
public PageReference
step1() {
return Page.OpportunityDecisionTree;
}
public
PageReference step2() {
//use account.State?
if(account.State){
return
Page.opportunitydecisiontree2;
}
}
public PageReference save()
{
insert opportunity;
PageReference opptyPage = new
PageReference('/' +
opportunity.id);
opptyPage.setRedirect(true);
return
opptyPage;
}
}
Can anyone help me with this?
Thanks!
- chriseustace
- November 19, 2009
- Like
- 0
- Continue reading or reply