• aborchy
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 5
    Replies

has anyone out there worked out how to hide the "New" button in the Oppty object? I want to either hide it or have it open/redirect to the Account object so that users have to review existing leads or account records before creating a new opp. In other words they have to create an opportunity from either a lead, contact or account record.

 

If y ou have code please share :)

 

Any help appreciated.

i have downloaded from the app exchange the contact required app and like it except that it produces a warning only for the user and forces them to back out and re-enter that data that is required. What I would like it to do is rather than create an error message is to open a new window with the contact role related list where the user can enter the required data and save. this would allow users to work without having to backout of the record.

 

It seems the code does what I want up until I get to the area highlighted in red text.

 

Apart of our business requirement is to capture contact and partner roles for each and every opportunity as it closes. I cant make a related list a requirement today so this seems to be the best work-around i have found. If anyone has any other solution please share :)

 

Any assistance is welcome.

 

 

 

 //This is provided as a sample to require a contact on opportunities it is provided without warranty and support.

trigger opportunity_contact_required on Opportunity (before insert, before update) {

//map to keep track of the contact_required = 1

Map<String, Opportunity> oppy_contact = new Map<String, Opportunity>();

//Trigger.new is an array of opportunities
//and adds any that have Contact_Required = 1 to the oppy_contact Map

for (Integer i = 0; i < Trigger.new.size(); i++) {

    if  (Trigger.new[i].contact_required__c == 1)
            {
            oppy_contact.put(Trigger.new[i].id,
            Trigger.new[i]);

            //system.debug('This is the trigger.new.id - '+Trigger.new[i].id);

    }
}

//map to keep track of the opportunity contact roles

map<Id, OpportunityContactRole> oppycontactroles = new map<Id, OpportunityContactRole>();


//select OpportunityContactRoles for the opportunities with contact role required

for (OpportunityContactRole ocr : [select OpportunityId, IsPrimary
from OpportunityContactRole
where (OpportunityContactRole.IsPrimary = True and OpportunityContactRole.OpportunityId
in :oppy_contact.keySet())])
  {


//puts the contact roles in the map with the Opportunity ID as the key
    
        oppycontactroles.put(ocr.OpportunityId,ocr);
}

// Loop through the opportunities and check if they exists in the contact roles map or contact role isn't required
        
for (Opportunity oppy : system.trigger.new) {

    //system.debug('List oppy Id - '+oppy.id);
    
    if  (oppycontactroles.containsKey(oppy.id) || oppy.contact_required__c ==0)
        {
            
        }
    
    else
        {
            oppy.addError('No Primary Contact Exists. Please go to the Opportunity Contact Roles Related List and add a primary contact.  Insure that all contacts related to this Opportunity are properly added in the Contact Roles with respective roles assigned.');

                
        }
    

} //for

    
    
 }

I have an issue in my org where a previous admin was happy to share the excel connector with some standard users however i want to stop this practice for all users except admins.

 

Any ideas???

***TRIGGER NEWBIE ALERT***

 

 

I have a custom Object "Goal" which houses a monthly quota for each rep.  Quota is based on several custom factors so using the standard RevenueForecast is not an option here.

 

I have a lookup from Opportunity to Goal and am trying to tally up the value of the New_Sales_Actual__c from the opportunity onto the ClosedBusiness__c field on the Goal record.

 

I found the example of how to do this 

 

I've tried this a number of ways and this one is the closest, except instead of totalling the value of New_Sales_Actual__c from all of the opportunities related to the goal, it counts the number of opportunities - so if I have 5 opportunities related to a goal valued at $1, $2, $2, $1, $1 instead of getting $7 in the ClosedBusiness__c field I get 5.

 

trigger OpportunityRollup on Opportunity (after delete, after insert,
after update) {
double sumNewSales = 0.00;

Set<id> goalIds = new Set<id>();
List<goal__c> goalsToUpdate = new List<goal__c>();

for (Opportunity item : Trigger.new)
goalIds.add(item.Goal__c);

if (Trigger.isUpdate || Trigger.isDelete) {
for (Opportunity item : Trigger.old)


goalIds.add(item.Goal__c);
}

Map<id,Goal__c> goalMap = new Map<id,Goal__c>([select id, ClosedBusiness__c
from Goal__c
where id IN :goalIds]);


for (Goal__c goal : [select Id, ClosedBusiness__c, (select id,
New_Sales_Actual__c from Opportunities__r) from Goal__c where Id IN
:goalIds]) {
goalMap.get(goal.Id).ClosedBusiness__c = goal.Opportunities__r.New_Sales_Actual__c.size();

goalsToUpdate.add(goalMap.get(goal.Id));
}

for (Goal__c goal : [select Id, ClosedBusiness__c, (select id,
New_Sales_Actual__c from Opportunities__r) from Goal__c where Id IN
:goalIds])

 

//**my playing around that didn't work


// {
// sumNewSales += goal.New_Sales_Actual__c;
// }

// goal.ClosedBusiness__c = sumNewSales;



update goalsToUpdate;

}

 

 

 

i have downloaded from the app exchange the contact required app and like it except that it produces a warning only for the user and forces them to back out and re-enter that data that is required. What I would like it to do is rather than create an error message is to open a new window with the contact role related list where the user can enter the required data and save. this would allow users to work without having to backout of the record.

 

It seems the code does what I want up until I get to the area highlighted in red text.

 

Apart of our business requirement is to capture contact and partner roles for each and every opportunity as it closes. I cant make a related list a requirement today so this seems to be the best work-around i have found. If anyone has any other solution please share :)

 

Any assistance is welcome.

 

 

 

 //This is provided as a sample to require a contact on opportunities it is provided without warranty and support.

trigger opportunity_contact_required on Opportunity (before insert, before update) {

//map to keep track of the contact_required = 1

Map<String, Opportunity> oppy_contact = new Map<String, Opportunity>();

//Trigger.new is an array of opportunities
//and adds any that have Contact_Required = 1 to the oppy_contact Map

for (Integer i = 0; i < Trigger.new.size(); i++) {

    if  (Trigger.new[i].contact_required__c == 1)
            {
            oppy_contact.put(Trigger.new[i].id,
            Trigger.new[i]);

            //system.debug('This is the trigger.new.id - '+Trigger.new[i].id);

    }
}

//map to keep track of the opportunity contact roles

map<Id, OpportunityContactRole> oppycontactroles = new map<Id, OpportunityContactRole>();


//select OpportunityContactRoles for the opportunities with contact role required

for (OpportunityContactRole ocr : [select OpportunityId, IsPrimary
from OpportunityContactRole
where (OpportunityContactRole.IsPrimary = True and OpportunityContactRole.OpportunityId
in :oppy_contact.keySet())])
  {


//puts the contact roles in the map with the Opportunity ID as the key
    
        oppycontactroles.put(ocr.OpportunityId,ocr);
}

// Loop through the opportunities and check if they exists in the contact roles map or contact role isn't required
        
for (Opportunity oppy : system.trigger.new) {

    //system.debug('List oppy Id - '+oppy.id);
    
    if  (oppycontactroles.containsKey(oppy.id) || oppy.contact_required__c ==0)
        {
            
        }
    
    else
        {
            oppy.addError('No Primary Contact Exists. Please go to the Opportunity Contact Roles Related List and add a primary contact.  Insure that all contacts related to this Opportunity are properly added in the Contact Roles with respective roles assigned.');

                
        }
    

} //for

    
    
 }

I need to figure out a way to make my team identify a primary contact for their opportunities once they reach a certain stage. Early stage opps will not require them because they are too early in the sales cycle.

 

But once they get to Stage 3 or higher, I want to require them. They have to be present so that when we generate the sales order form, it knows which contact to indicate on the form. Some of my reps are adding the contact manually on the form after it is generated - but that means there is no one identified on the Opp in SFDC, which is where it should be.

 

Any ideas?

 

Thanks,

Jane