• mallikam
  • NEWBIE
  • 100 Points
  • Member since 2009

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 36
    Questions
  • 74
    Replies
I deployed some fields and validation rules related to a particular object onto clients production through Eclipse. This deployment updated all the profiles with my name? Is this a default action or is this a bug or how is this possible? Because, when I deploy an object, how come all the profiles are updated with my name? Any help is appreciated.
I know we can retrict triggers to profiles but can we restrict triggers to certain page layouts only? thanks!

I have the following trigger which checks off the Executive for every new Case based on the Executive value in Contacts.

 

trigger Executive on Case (before insert, before update) { Map<Id, Case[]> contactCaseMap = new Map<Id, Case[]>(); For (Case ncase:Trigger.new) { Id cid = ncase.contactId; If (cid != NULL) { if(contactCaseMap.get(cid) == null) contactCaseMap.put(cid, new Case[]{}); contactCaseMap.get(cid).add(ncase); } } For(Contact c:[select Executive__c from Contact where Id IN :contactCaseMap.keySet()]) { for(Case ncase:contactCaseMap.get(c.id)) { ncase.Executive__c = c.Executive__c; } } }

 

 

It works fine except that every now and then I get following exception in email from Production.

 

Apex script unhandled trigger exception by user/organization: xxxxxxxxxxxxx/xxxxxxxxxxxx 

Executive: execution of BeforeInsert

 

caused by: System.Exception: Too many SOQL queries: 21

 

Trigger.Executive: line 12, column 17

 

 

But I dont see what wrong with my code. Nevertheless, I changed the code to following avoiding many for loops:

 

trigger Executive on Case (before insert, before update) { Map<Id, Case[]> contactCaseMap = new Map<Id, Case[]>(); Id cid; Contact d = new Contact(); for (Case ncase:Trigger.new) { cid = ncase.contactId; if (cid != NULL) { if(contactCaseMap.get(cid) == null) contactCaseMap.put(cid, new Case[]{}); contactCaseMap.get(cid).add(ncase); } } if (cid != NULL) { list<Contact> c = [select Executive__c from Contact where Id IN :contactCaseMap.keySet() limit 1]; if (c.size()!=0) {d=c[0];} Trigger.new[0].Executive__c = d.Executive__c; } }

 

 

But I get the same exact exception still every other day. I am not able to understand whats going wrong. Any help?

Hi,

 

I have a trigger with the following code, everything seems to be working fine until I got the above exception through email this morning. The code looks simple and correct to me an so I am having hard time figuring out why the query could have run into governor limits exception..

 

trigger Executive on Case (before insert, before update) { Map<Id, Case[]> contactCaseMap = new Map<Id, Case[]>(); For (Case ncase:Trigger.new) { Id cid = ncase.contactId; If (cid != NULL) { if(contactCaseMap.get(cid) == null) contactCaseMap.put(cid, new Case[]{}); contactCaseMap.get(cid).add(ncase); } } For(Contact c:[select Executive__c from Contact where Id IN :contactCaseMap.keySet()]) { // code is // running into exception at this // query

 

Thanks!

How can we  redirect a trigger to a standard salesforce URL? Like when the user updates a cutom field in Opportunity, I want him to go to the new Partner reated list page directly when he hits save. Usually you can only see the new partner page only when you click New in Partner subsection from the opportunity details page. But I want to mandate the partner related list page when user selects YES for a custom field in Opportunity page.

I have created some parent and respective child cases in Case object. Now, I want to make parent case not closable unless child cases have been closed..in other words, somebody should not be able to set the status of parent case to closed unless they have closed all the child cases. I am thinking to do this with triggers...but I have no idea how..any help is appreciated.

I am trying to add a warning message like "Are you Sure" before Saving an Opportunity. I do not know how to over ride the save button. Could someone help me on this please?

 

Thanks
Venkat

I am trying to figure out a way to effectively redirect the user to a VisualForce page after a new opportunity is created, while passing in the ID of the new Opportunity. The overall objective is to require the user to enter additional information about the Opportunity on a separate screen. I'd also like to avoid completely recreating the Opportunity edit page in VF so that the admins can still add/change fields and use the PageLayout Editor.

 

My thought was that I could use the standard Opportunity Controller on a VF page and then use <apex:detail>, however it doesn't seem like it's possible to call an Apex page for a new record unless you're manually building the form. For example:

 

  • https://na6.salesforce.com/006/e?retURL=/apex/OppPart2/id=newOppID - This would redirect the user to a specific page after the save has completed, but there's no way to know the newOppID ahead of time.
  • https://na6.salesforce.com/apex/NewOpportunity/e - Calling a VF page with the standard /e at the end fails with an error
  • https://na6.salesforce.com/apex/NewOpportunity?ID= - Calling a VF page with a blank ID parameters displays a blank screen.


Does anyone know of a way to either:

  • Override the [Save] button functionality on a New Opportunity without recreating the entire edit form in VF?
  • Create a VF page that can determine the ID of the Opportunity just created
  • Any other way to have display a specific VF page after creating a new opportunity?


Thanks for your help.

 

Mike

I would like to redirect to a Visualforce page I've created when a user saves an Opportunity, and the Opportunity is closed/won. I've written a trigger to test the logic and the new VIsualforce page, but I'm stumped on how to accomplish the redirect because apparently according to this thread: http://community.salesforce.com/sforce/board/message?board.id=apex&message.id=3321 you can't redirect from a trigger.

Does anyone have any ideas on how to accomplish this?

Thanks in advance...