• 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 created some custom fields and validation rules under under Opportunity standard object. Then I added these to my project through add/remove componenets. Then I deployed the Opportunity object onto the production.

 

Is this the right way to deploy my new stuff onto production? For classes or triggers, it would show me what exactly is being updated on production. I dont think it showed me that for Opportunity object.

 

The problem now is that whole opportunity object got updated on production. Did I do something wrong? And there is no way to go back, thats the worst part!! Any help is greately 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?

I have a custom button for one of my standard objects and it disappears when I inline edit..can I make them appear somehow?

 

thanks!

I have written the following code for VF page and I have overrided opportunity new button with this page:

 

<apex:page standardController="Opportunity"> <script> window.top.location.replace("{!URLFOR($Action.Opportunity.New, opportunity.id, [saveURL='/apex/oppRedirect', retURL='/'+opportunity.id, cancelURL='/'+opportunity.id], true)}"); </script> </apex:page>

 

The problem is that when I click new opportunity, I am directed to another page that has a pick list to select tha opportunity type. When I selct the opportunity type and hit continue, I am getting redirected to the same page! But when I hit continue again, I am getting redirected to the next page correctly..I am unable to fix the problem of getting redirected to the same page when I click continue first time though..any help is appreciated!

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 want to show partner related list on a custom field update(if yes) in opportunity. The partner related list is usually visible only after you save a opportunity and you can only edit it after you click new Partner.

 

I am thinking of doing this with work flow and s-control but have no idea how I can do it. I mean I dont know how can you or where you should reference a s-control with workflow?

 

 

Basically, I want to mandate the partner related list in opportunity when the user changes a custom field(picklist) to yes in opportunity. I have number of fields and I want user to fill the respective partner related list for each field that they say yes.

 

thanks!!

Message Edited by mallikam on 09-23-2009 01:44 PM
Is it possible to clone the standard object using AJAX or any other way in VF page?
Message Edited by mallikam on 09-08-2009 10:34 AM

1. If a value is selected from a custom pick list, can we make some other fields in the section mandatory say for example in Accounts object? If so, should I write a workflow for achieving this?

 

2. Can I display an alert message when a value is selected?

 

3. If I want to write java script code for standard object, is that possible?

 

Any answers are appreciated.

I have the following function which is being called on page submit for my visual force page. I am getting the following error when the user hits submit

 

Record ID: cannot Specify ID in an Insert Call

 

And the code is below

public PageReference confirm() {

case ticket = new case();

if (this.request != null) {

request.Title__c = this.empTitle;request.Department__c =

this.empDept; request.Reports_to__c = this.repToEmail;

 

try {

insert request; } catch (system.DMLException e){

ApexPages.addMessages(e);

return null;

}

this.caseId1 = generateNewTicket(request.employee_name__c, request.Grant_Email_access_to__c,

request.Outlook_out_of_office_message__c, request.Blackberry_user__c );

if (this.caseId1 == NULL)

return null;

}

 

list<Case> a = [Select c.CaseNumber from Case c where c.Id = :this.caseId1 limit 1];

if(a.size() != 0) {ticket = a[0];}

this.confNumber = ticket.CaseNumber;

 

try{ sendEmail(this.confNumber);

sendEmail();

} catch (EmailException e){

ApexPages.addMessages(e);

return null;

}

PageReference p = Page.offbsubmit;

p.setRedirect(true);

return p;

}

 

It says problem with insert but I see the new request was created! But I did not get any emails, so may be it was

choking at that part but I dont understand why. Any help please?

If so, please provide an example.

 

thanks!

My site is controlled by a VF page which is controlled by a Apex Controller extension. When I hit submit on sites, automated emails are sent to the people. The from address of these automated emails is displaying my email address but I want it to display a generic email address of the company that is hosting the site. How can I do it? Any help is appreciated.

I have the following code in one of the controller extension methods:

 

confirm() { 

PageReference p = Page.offbsubmit;

p.setRedirect(true);

return p;

}

 

I am testing the above code in testMethod using the following statement..

 

PageReference q = test.confirm();

PageReference s = Page.offbsubmit;

system.assertEquals(q, s); // getting an exception here!!

 

I am getting the following exception:

 

System.Exception: Assertion Failed: Expected: System.PageReference[/apex/offbsubmit], Actual: System.PageReference[/apex/offbsubmit] 

 

which doesnt make anysense to me because the expected and the actual values are the same..any help?

 

Message Edited by mallikam on 07-28-2009 11:10 AM

Following an example, I have written the following statement in my trigger after update which is activated when a child case is closed:

 

list<Case> a = [Select Id from Case where Id = :Trigger.New[0].ParentId and Subject = 'Delete Network ID or Reset password' limit 1];

if(a.size() != 0) { b = a[0];}

 

It works just fine! Then, I thought why cant I just have a single sboject instead of a list of sobjects and I changed the above to

the following:

 

Case a = [Select Id from Case where Id = :Trigger.New[0].ParentId and Subject = 'Delete Network ID or Reset password' limit 1];

 

This statement is throwing an exception when I try to close a child case if the parent objects subject is not a 'Delete Network ID or Reset password'.

 

System.QueryException: List has no rows for assignment to SObject

 

Why so? I did not understand exactly how a list is making the difference?

 

 

I wrote a trigger after update for child cases. If all the child cases are closed, the Inactive field of the ContactId reference of the parent case will be set to true...I am getting an exception with the following code, when I try to close the last child case. Its then trying to evaluate the innermost if condition and hitting the exception..

trigger childsClosed on Case (after update) { Case b = new Case(); if (Trigger.New[0].Status == 'Closed') { if (Trigger.New[0].ParentId != null) { list<Case> a = [Select Id from Case where Id = :Trigger.New[0].ParentId and Subject = 'Delete Network ID or Reset password' limit 1]; if(a.size() != 0) { b = a[0];} if (b.Id != null) { integer childCases = [Select count() from Case where ParentId = :b.Id]; integer closed = [Select count() from Case where ParentId = :b.id and Status = 'Closed']; if (closed == childCases) { b.Contact.Inactive__c = true; } } } } }

And I am getting the exception that says:

 

Apex script unhandled trigger exception by user/organization: 005700000018KNh/00D70000000JLCa

 

childsClosed: execution of AfterUpdate

 

caused by: System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Case.Contact

 

Trigger.childsClosed: line 12, column 6

 

Should I write a trigger to do this? Do I have a better/easier option than writing a trigger?

I am unable to create a record through sites which is integrated with a visual force page. I have the read, create, edit permissions checked for the custom object on public access settings. I can create the records through the VF page that the sites refers to but I am unable to create the same through sites. Any help? Here is the controller code that is being called when I hit submit button and expect the record be created..

 

public PageReference confirm() {

if (this.request != null) {

 try {

       insert request; }

catch (system.DMLException e){

      ApexPages.addMessages(e);

 

       return null;

}

PageReference p = Page.submit;

p.setRedirect(true);

return p;

}

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 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...