• dbake
  • NEWBIE
  • 0 Points
  • Member since 2010


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 9
    Replies
triger on account which matches email and phone of the associated account, if both match then only insert contact record else throww error
trigger MatchPhoneonAccount on Contact (before insert)
{
    set<id> accIdset = new set<id>();
    for(Contact c :trigger.new)
    {
        if( c.accountid!=null)
            {
             accIdset.add(c.AccountId);
            }
    }
     map<id,account> accMap = new map<id,account>([Select id,Email__c , Phone from account where id in : accIdset]);
     
     
    for(contact c : trigger.new)
    {
         if(c.Email != null && c.Phone != null && accMap != null)
         {
          system.debug('*******Email'+c.Email);
          system.debug('*******Phone'+c.Phone);
            if(c.Email != accMap.get(c.accountid).Email__c &&  c.Phone != accMap.get(c.accountid).Phone)
            {
            system.debug('*******Dosent Matched'+c.Phone);
             c.adderror('Your phone and Email does not exists in out database .');
            }
         }
    
    }
}

no debug logs are generate and even though account and contact email, phone are different , the trigger dosent fire .
When an opportunity closes to won, I want a chatter update to a specified chatter group (which i dont have listed)
I tried editing this code from someone but need some assistance

trigger OppWonChatter on Opportunity (after insert, after update) {

String status;
String OppAccName;
String OppOwnerName;
FeedItem post = new FeedItem();
    
    for(Opportunity o : Trigger.new) {
        if(o.OwnerId == '00560000001MxXV') { //It will not post record for for this user to group. changed last letter to cap v so i can test
            return;
        }
        else {
            if(Trigger.isInsert ) {
                if( o.IsWon == true ) { //This will be executed on new record insertion
                    for (Opportunity oppty : [SELECT Account.Name, Owner.Name FROM Opportunity WHERE Id =:o.Id] ) {
                        OppAccName = oppty.Account.Name;
                        OppOwnerName = oppty.Owner.Name;
                    }    
                    status = OppOwnerName + ' just won ' + OppAccName + ' for ' + o.expectedrevenue + '!';

                    
                    post.ParentId = OppAccName;
                    post.Title = o.Name;
                    post.Body = status;
                    
                    insert post;
                }
            }    
            else {
                if ( Trigger.isUpdate ) {
                    if( o.IsWon == true && Trigger.oldMap.get(o.id).IsWon == false) { //This will be executed on update to existing record
                        for (Opportunity oppty : [SELECT Account.Name, Owner.Name FROM Opportunity WHERE Id =:o.Id] ) {
                            OppAccName = oppty.Account.Name;
                            OppOwnerName = oppty.Owner.Name;
                        }    
                        status = OppOwnerName + ' just won ' + OppAccName + '!';
                            
                        post.ParentId = OppAccName;
                        post.Title = o.Name;
                        post.Body = status;
                        
                        insert post;      
                    }
                }
            }
        }
    }    
}
My selectList is continuously passing null as the value to my controller and i dont know why. What am i missing! Thanks! Code Below

VisualForce Page
<div class="form-group">
                                                <label><apex:outputText value="{!$Label.Fee_Select_Default_Fee}"></apex:outputText></label>
                                                <apex:selectList styleClass="form-control" value="{!RemoveFeeSelected}" size="1">
                                                    <apex:selectOptions value="{!RemoveFeeList}"/>
                                                    <apex:actionSupport event="onchange" action="{!NULL}" reRender="TheRemoveListPanel,messages" status="removeselectstatus"/>
                                                </apex:selectList>
                                                <apex:actionStatus id="removeselectstatus">
                                                    <apex:facet name="start">
                                                        <img src="/img/loading.gif"/>
                                                    </apex:facet>
                                                </apex:actionStatus>
                                            </div><!-- /.form-group -->
                                            <div class="form-group">
                                                <label><apex:outputText value="{!$Label.Fee_Select_Join}"></apex:outputText></label>
                                                <apex:outputPanel id="TheRemoveListPanel">
                                                    <apex:selectList styleClass="form-control" value="{!TodeletePFT}" multiselect="true" size="6">
                                                        <apex:selectOptions value="{!RemoveJoinList}" id="theremovelist"/>
                                                    </apex:selectList>
                                                </apex:outputPanel>
                                            </div><!-- /.form-group -->

Apex Class
Public Id RemoveFeeSelected {get;set;}
Public String[] TodeletePFT {get;set;}

public FeeManagementController() {}


//Used for Picklist for Removal Fee Modal
    public List<SelectOption> getRemoveFeeList() {
 	 	List<SelectOption> FeeList = new List<SelectOption>();
 	 	List<Template_Records__c> TempateFees = [SELECT Id, Text_Field_1__c FROM Template_Records__c];
 	 	FeeList.add(new SelectOption('null','-- None Selected --'));
 	 	for (Template_Records__c t: TempateFees) {
 	 		FeeList.add(new SelectOption(t.Id,t.Text_Field_1__c));
 	 	}
 	 	
 	 	return FeeList;
  	}

//Used for Picklist for Removal Fee Modal
  	Public List<SelectOption> getRemoveJoinList() {        
        System.debug('**' + RemoveFeeSelected);
  		List<SelectOption> RemoveList = new List<SelectOption>();
		List<PFT_Join__c> JoinList = [SELECT Id, Name, Template_Records__r.Text_Field_1__c, Product_Feature__r.Name FROM PFT_Join__c WHERE Template_Records__c = :RemoveFeeSelected];
  		for (PFT_Join__c pft: JoinList) {
  			RemoveList.add(new SelectOption(pft.Id, pft.Name + ' - ([' + pft.Template_Records__r.Text_Field_1__c + '] - [' + pft.Product_Feature__r.Name + '])'));
  		}

  		return RemoveList;
  	}

 
A custom field named Calls_Made__c is numeric and increments by 1 each time an outgoing call task is completed.

This happens in two areas, on the Lead and on the Account (opportunity) - (seperate counts for each)

The Lead update works fine, but am having trouble with the acount count incrementing on the opportunity task completion.
 
trigger UpdateLeadOpenTasks on Task (after delete, after insert, after undelete, after update) {
 
System.Debug('Runnning UpdateLeadOpenTasks');
 
// Declare the variables
 
public set<Id> LeadIDs = new Set<Id>();
public list<Lead> LeadsToUpdate = new List<Lead>();
public set<Id> AccountIDs = new Set<Id>();
public list<Account> AccountsToUpdate = new List<Account>();
 
// Build the list of Leads and Accounts to update
 
if(Trigger.isInsert || Trigger.isUnDelete || Trigger.isUpdate){
 
System.Debug('Creating a list of IDs to update');
 
    for(Task t: Trigger.new){       
    System.Debug(t.WhoId);
  
        if(t.WhoId !=null) {
        //We need to put something here to handle a fail if the user doesn't link an activity to a Account or Lead

            if(string.valueof(t.WhoId).startsWith('003')) {
                // nothing with contact
                System.Debug('No Task WhoID set for Contact');
            } else if(string.valueof(t.WhoId).startsWith('00Q')) {
                LeadIDs.add(t.WhoId);
            } else {
                AccountIDs.add(t.WhoId);
            }

    
        }
        else {
        System.Debug('No Task WhoID set');
        }
 
    } //end for
}
if(Trigger.isDelete){
    for(Task t: Trigger.old){
        if(string.valueOf(t.WhoId).startsWith('00Q')){
            // leads
            LeadIDs.add(t.WhoId);
         }else if(string.valueOf(t.WhoId).startsWith('003')){
            // nothing for contact
            System.Debug('No Task Trigger set for Contacts'); 
        } else {
            // account
            AccountIDs.add(t.WhoId);
        }
    }
}
 
// Update the Leads
 
if(LeadIDs.size()>0){
   System.Debug('Lead has at least 1 record - doing something');
   for(Lead l: [Select l.Id, l.Calls_Made__c,
   (Select Id From Tasks where CallType='Outbound' and Status='Completed') //Change   select statement to just be NVM Tasks
   From Lead l where Id in :LeadIDs])
   LeadsToUpdate.add(new Lead(Id=l.Id, Calls_Made__c = l.Tasks.size()));
   update LeadsToUpdate;
 
}
 
// Update the Accounts
if(AccountIDs.size()>0){
System.Debug('Account has at least 1 record - doing something');
//We need to put in code to handle it if we don't know who the Account is
 
for(Account c: [Select c.Id, c.Calls_Made__c,
(Select Id From Tasks where CallType='Outbound' and Status='Completed')//Change select statement to just be NVM Tasks
From Account c where Id in :AccountIDs])
AccountsToUpdate.add(new Account(Id=c.Id, Calls_Made__c = c.Tasks.size()));
update AccountsToUpdate;
}
 
}

 

The requests are as follows:

 

I have two check boxes on activities that I would like to
have update two date fields on the parent object (in this case person accounts)
with Today's date.

 

I have a number field on person accounts that needs to
count the total number of associated activities. Just like a roll up summary.

 

Please let me know an approximated quote for
this job and approximate completion date. Also, if there are any questions, please
do not hesitate to ask.

Our company provides Human Resource support to other small and medium sized businesses.  We have created a number of Human Resource oriented programs in Excel for our clients.  We would like these to be accessed via SalesForce to control ownership of the content. 

 

* Each worksheet represents one week of work for an employee. Hours worked by day are posted, revenue and commissions are posted as applicable and there are calculations done to determine overtime hours.

 

* This needs to have a professional feel and can't have extended delays when posting.

* A demonstrated track record f success is required.  

 

This is the first of multiple projects.  SalesForce may not be the best platform for this solutions, but it is our first choice. 

 

 

  • September 30, 2011
  • Like
  • 0

Hi Folks. I posted the last post on this board about a small project, but its priority has been shifted to finding a solution for a new problem/project over here.

 

I'm not sure if this would be a good fit for the force.com, or if there is another platform that makes more sense for a spreadsheet-style software app so we don't need to build a ton of visualforce pages. I appreciate your input and look forward to speaking with you. 

 

STATEMENT OF PROBLEM

 

I currently have an Excel file/workbook with approximately 20 different worksheets /pages. The workbook is a financial reporting system of business activities. It is NOT an accounting software.


When it was created as an Excel spreadsheet, cell values were linked throughout the workbook to reduce chances for human transcribing and calculation errors.


Since the business is an ongoing entity, the workbook would have to create anew set of worksheets for each new week. Over time, the file began to slow down significantly as the sheer volume of worksheets it had to comb through to update current week data cells became to cumbersome.


It was suggested to me that this time of reporting system should have been set up in a database writing software instead of a spreadsheet.


OBJECTIVE


What I am seeking to accomplish are the following objectives:


1) I need my worksheets recreated in a way that pulls and populates data in the appropriate places quickly and accurately.

2) I need to be able to add a new set of worksheets each week, ideally by clicking a button.

3) I need this to be available in the cloud so that it can be accessed from any computer system with a username and password.

4) It will need at least two access levels (user & manager) and ideally have a third access level for administrator/ owner.

5) I need to make it reproducible so that 10,000 different accounts can be created and sold with access available to only their own account information and data.

 

 

Thank you,
Mat 

Hello,

 

I'm looking for a Salesforce and cmsforce expert to prepare a landing page on a force.com site for me.

I need to email an existing contact a link to register for an event, and to update his contact details in the process. This would be done on a Force.com site.

 

This needs to be done quite urgently. It is a fairly straightforward job.

 

Thanks,

Jake

  • September 28, 2011
  • Like
  • 0