• Krishnadas
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 15
    Replies
Hi,

I am encountering problems in a mass delete. I am passing all the records that needs to be deleted to a list and then giving one command to delete the list. Would this be considered as 1 DML statement?
Correct me if I am wrong, the maximum list size is 1000 and the maximum number of DML statements allowed is 100 so Ideally I should be able to delete 100 lists or 100000 records.

For example
I am trying to delete a list of records in Object1
Object1List = [select Id from Object1];
delete Object1List;
lets say that size of Object1List is 250. So when I delete the Object1List will it be counted as 1 DML statement or as 250 DML Statements.

I keep getting Too Many DML rows for the same situation in my development environment.

Thanks
Krishnadas
www.steadfastglobal.com
Hi,

I am writing a trigger that runs on a before delete event. I am also trying to use the @future call. I am not sure whether I am using it correctly and require some help. I have 3 objects Obj1__c, Obj2__c, Obj3__c that are related but not in a Master-Detail way.
There is a field Qty__c in Obj1__c. Depending on the value entered for Qty it creates that many Obj2__c with reference to Obj1__c. Every Obj2__c can have Obj__3 associated to it. What I am trying to do is a Cascade delete. When I delete one Obj1__c record, I would like to delete all Obj2__c records and when the Obj2__c records are deleted I would like to all Obj3__c records associated with it.
The problem I face is that I either keep entering DML row exception or Query rows exception. To overcome this I tried the @future option, though I hardly get any errors but it does not delete too. And the ApexJobs shows them as complete while the Batch Processed shows as 0.
I am attaching the latest code I tried to achieve this.

Thanks
Krishnadas
www.steadfastglobal.com
 

trigger recDelete on Obj1__c (before delete) { Set<Id> obj1Id = new Set<Id>(); for(Obj1__c obj1 : trigger.old) { obj1Id.add(obj1.Id); } triggerController.deleteObj1(obj1Id);}public class triggerController { @future public static void deleteObj1(Set<Id> obj1) { List<Obj1__c> obj1List = new List<Obj1__c>(); List<Obj2__c> obj2List = new List<Obj2__c>(); List<Obj3__c> obj3List = new List<Obj3__c>(); Set<Id> obj2 = new set<Id>(); double Qty, obj2DelQty, obj3DelQty; double obj2Count, obj3Count; obj1List = [select Id, Qty__c from Obj1__c where Id in :obj1]; for(Obj1__c o1 : Obj1List) { Qty = o1.Qty__c; } obj2DelQty = Qty; while(obj2DelQty > 0) { obj2List = [select Id from Obj2__c where Obj1Id__c in :obj1 limit 999]; obj3Count = [select id from Obj3__c where Obj2Id__c in :obj2List]; obj3DelQty = obj3Count; while(obj3DelQty > 0) { obj3List = [select Id from Obj3__c where Obj2Id__c in :obj2List limit 999]; obj3DelQty = obj3DelQty – obj3List.size(); delete obj3List; } obj2DelQty = obj2DelQty – obj2List.size(); delete obj2List; } }}

 

 

Hi,

I have created a before insert trigger on a custom object Object1__c which will create records for another custom object Object2__c. There is a before insert trigger in Object2__c that will create records for the 3rd custom object Object3__c. Earlier I used to get governor limit errors on SOQL queries as they were inside a loop. Now I keep getting error on List size being above 1000. Could I catch and exception and show it as an error in the visualforce page. How do I caluclate for the limit.

Thanks

Krishnadas

www.steadfastglobal.com 

Hi,

I have a Visualforce page that overrides the New button for a custom object. I have a quantity field with the inputtext tag and parameter assigned to it.
In the controller class I have set it up as double so that only numeric values will be accepted. All this is working fine except for the error I receive.
This is the error that I get now if try to enter characters and click on save
j_id0:form1:pb1:pbs2:j_id46:qty: An error occurred when processing your submitted information.
I do not want this. How do I avoid it?

Thanks
Krishnadas
Steadfast Global
www.steadfastglobal.com
Hi,

I have created some visualforce pages that override the new and edit functions of custom objects. In the Edit Visualforce page I have shown some fields as output only so that the user cannot change the values in it. I did it using the <apex:outputField> tag. 
There are other fields where the user can modify the value. I also have some validation rules set on them. The issue that I face is that when I encounter an validation error on the UI I loose all the values from the page and it shows blank. This is not an issue all times. It happens very rarely to be precise the VF page works fine 99% of the time and looses value 1% of the time.
Could some point out the reason that the page could loose the value. I also notice when this happens I also loose all the Ids that are there in the URL. Any pointer or suggestion could be very helpful.

Thanks
Krishnadas
Steadfast Global
www.steadfastglobal.com
Hi,

I have created a visualforce page and a have also create a controller class for it.
I have created a command button for 'Cancel' in the Visualforce page. The action refers to a pagereference method in the controller class.
The pagereference method performs the function of redirecting to a different page of my choice. Redirect is set to true.
I encounter a problem with this in one scenario.
There is an input field in the visualforce page which is a lookup to different object. If I type something in the text space instead of selecting from the list and then click on Cancel, it does not work it stays in the same page and throws an error. Once I delete the text the Cancel button works.
What is happening? How do I get the Cancel to work all times.

Thanks
Krishnadas
Steadfast Global
www.steadfastglobal.com
Hi,
I used a developer edition Id to create an Application, I was able to create a Managed package of the application. When clicking upload I keep getting the error “Insufficient Privileges” “You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary”.
The fact is that I am the System Administrator. 
I am unable to place this error and upload the package.

Any help on this is greatly appreciated.

Thanks
Krishnadas
Applications Engineer
Steadfast Global
www.steadfastglobal.com
 
Added: Case number 02827828 is created for this issue.
Message Edited by Krishnadas on 07-29-2009 02:48 AM
Hi,

I am writing a trigger that runs on a before delete event. I am also trying to use the @future call. I am not sure whether I am using it correctly and require some help. I have 3 objects Obj1__c, Obj2__c, Obj3__c that are related but not in a Master-Detail way.
There is a field Qty__c in Obj1__c. Depending on the value entered for Qty it creates that many Obj2__c with reference to Obj1__c. Every Obj2__c can have Obj__3 associated to it. What I am trying to do is a Cascade delete. When I delete one Obj1__c record, I would like to delete all Obj2__c records and when the Obj2__c records are deleted I would like to all Obj3__c records associated with it.
The problem I face is that I either keep entering DML row exception or Query rows exception. To overcome this I tried the @future option, though I hardly get any errors but it does not delete too. And the ApexJobs shows them as complete while the Batch Processed shows as 0.
I am attaching the latest code I tried to achieve this.

Thanks
Krishnadas
www.steadfastglobal.com
 

trigger recDelete on Obj1__c (before delete) { Set<Id> obj1Id = new Set<Id>(); for(Obj1__c obj1 : trigger.old) { obj1Id.add(obj1.Id); } triggerController.deleteObj1(obj1Id);}public class triggerController { @future public static void deleteObj1(Set<Id> obj1) { List<Obj1__c> obj1List = new List<Obj1__c>(); List<Obj2__c> obj2List = new List<Obj2__c>(); List<Obj3__c> obj3List = new List<Obj3__c>(); Set<Id> obj2 = new set<Id>(); double Qty, obj2DelQty, obj3DelQty; double obj2Count, obj3Count; obj1List = [select Id, Qty__c from Obj1__c where Id in :obj1]; for(Obj1__c o1 : Obj1List) { Qty = o1.Qty__c; } obj2DelQty = Qty; while(obj2DelQty > 0) { obj2List = [select Id from Obj2__c where Obj1Id__c in :obj1 limit 999]; obj3Count = [select id from Obj3__c where Obj2Id__c in :obj2List]; obj3DelQty = obj3Count; while(obj3DelQty > 0) { obj3List = [select Id from Obj3__c where Obj2Id__c in :obj2List limit 999]; obj3DelQty = obj3DelQty – obj3List.size(); delete obj3List; } obj2DelQty = obj2DelQty – obj2List.size(); delete obj2List; } }}

 

 
Hi,

I have a Visualforce page that overrides the New button for a custom object. I have a quantity field with the inputtext tag and parameter assigned to it.
In the controller class I have set it up as double so that only numeric values will be accepted. All this is working fine except for the error I receive.
This is the error that I get now if try to enter characters and click on save
j_id0:form1:pb1:pbs2:j_id46:qty: An error occurred when processing your submitted information.
I do not want this. How do I avoid it?

Thanks
Krishnadas
Steadfast Global
www.steadfastglobal.com
Hi,

I have created a visualforce page and a have also create a controller class for it.
I have created a command button for 'Cancel' in the Visualforce page. The action refers to a pagereference method in the controller class.
The pagereference method performs the function of redirecting to a different page of my choice. Redirect is set to true.
I encounter a problem with this in one scenario.
There is an input field in the visualforce page which is a lookup to different object. If I type something in the text space instead of selecting from the list and then click on Cancel, it does not work it stays in the same page and throws an error. Once I delete the text the Cancel button works.
What is happening? How do I get the Cancel to work all times.

Thanks
Krishnadas
Steadfast Global
www.steadfastglobal.com

Hope someone can help me.

 

I need to create a validation rule for this scenario:

 

User "A" creates a record in custom object and leaves Compromise Proposal Date field blank. This field is Date type.

User "B" enters the record and types a valid date in Compromise Proposal Date field.

Once user "B" enters a date, no one must be able to modify it.

 

Thanks 

  • July 31, 2009
  • Like
  • 0

Hello,

 

I have a user that wants a formula field that figures a person's age at the time of the opportunity create date. I have a formula in place to determine the person's current age, however, that will change from year to year. I am not seeing an option to subtract their birth year from the Opp. Created year (2009 - 1944 = 65) without adding additional fields, which he does not want. Any help would be appreciated.

 

Thanks!

  • July 30, 2009
  • Like
  • 0

 

Below is my Apex class and test method. when i run my test i am receiving the error

 

System.QueryException: List has no rows for assignment to SObject (and this is for the line where i am quering sales_office custom object)

 

Can some one please guide me how to write test methos for the code below?

 

Thanks very much in advance for the help

public class Accountdelete { Id AcctId = ApexPages.currentPage().getparameters().get('id'); public Account getAccountName() { return [Select Name from Account where id=:AcctId]; } public PageReference Reassign() { Account acct=[Select Named_Account__c,RegionName__c,ownerid from Account where id=:AcctId]; Sales_Office__c salesoffice=[Select sales_Administrator__c from sales_Office__c where name=:acct.RegionName__c]; String res=''; Integer count=(acct.product_type__c).indexOf('QAC'); if(count>-1) { res=(acct.product_type__c).replace('QAC',''); } acct.product_type__c=res; acct.ownerid=salesoffice.Sales_Administrator__c; update acct; return null; } public static testMethod void results() { Id id; Account testAccount =new Account(Name='Sample2',RecordTypeid='0123000000002GvAAI',NumberOfEmployees=10,BillingStreet='71 Maple st, BillingCity='Doral', BillingState='FL', BillingPostalCode='33172', BillingCountry='US',phone='1111111111',RegionName__c='Miami'); insert testAccount ; Sales_Office__c Salesoffice=new Sales_Office__c(SALES_ADMINISTRATOR__C='00530000000f5H6AAI',NAME=testAccount.RegionName__c); insert Salesoffice; ApexPages.currentPage().getParameters().put('id', testAccount.id ); id = ApexPages.CurrentPage().getParameters().get('id'); Accountdelete test=new Accountdelete(); test.getAccountDetails(); test.Reassign(); } }

 

Message Edited by mavs on 07-30-2009 01:51 PM
  • July 30, 2009
  • Like
  • 0
Hi,
I used a developer edition Id to create an Application, I was able to create a Managed package of the application. When clicking upload I keep getting the error “Insufficient Privileges” “You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary”.
The fact is that I am the System Administrator. 
I am unable to place this error and upload the package.

Any help on this is greatly appreciated.

Thanks
Krishnadas
Applications Engineer
Steadfast Global
www.steadfastglobal.com
 
Added: Case number 02827828 is created for this issue.
Message Edited by Krishnadas on 07-29-2009 02:48 AM

I've tried a couple solutions found on the boards but I always seem to get CANNOT_INSERT_UPDATE.. error when I try to update a field on a parent object from a ''after update'' or ''after insert'' trigger on the child (''before update'' or ''before insert'' doesn't work).

 

I've put an quick example of how I've made my trigger:

 

trigger opp_update on Child_Object__c (after update, after insert) {

for( Child_Object__c child: Trigger.new){
 ID parent_ID= child.Opportunity__c;
 

Opportunity opp_to_update= [select field_to_update__c from Opportunity where id =: parent_ID];
 opp_to_update.
field_to_update__c = 7777;
 

update opp_to_update;
 }
 
}

 

Does someone have a quick tip to help me solve this?

Hi. I'm a newbie, so this may be a simple question to answer.

 

I have 2 custom objects: an Application (e.g. for a mortgage), and Client, connected by a lookup relationship. An application can have 1 or more Clients, and the Client includes fields First_Name & Surname (Text, External ID) and ApplicationLUP (Lookup(Application)).

 

When I click on my Applications tab and search for an Application in the search field (left hand bar), I'd like to be able to search by name of the child Client, first name or surname,as well as Application ID. So searching for "Smith" will return me all Applications with a Client named Smith. How is this done?

 

Many thanks!

Richard

I'm really new in this and would appreciate any pointers. I read through examples but still not sure how to proceed. TIA.

 

 

/*** Controller ***/
public class MyControllerExtension {

    private final Opportunity oppor;
   

    public myControllerExtension (ApexPages.StandardController stdController) {
        Id id = ApexPages.currentPage().getParameters().get('Id');
       
        oppor = (id == null) ? new Opportunity() :
                [
                 SELECT Id, StageName, Account_Region__c                

                 FROM Opportunity
                 WHERE Id = :id
                ];
    }

 

    public Opportunity getOpportunity() {

        return oppor;

    }

 

   
    public String getButtonState() {
 
        if(oppor.Account_Region__c == 'UK') {
            if(oppor.StageName == 'Closed Won') {
               return 'False';
            } else {
              return 'True';
            }
        } else {
            return 'True';
        }
    }   

}

 

/*** TEST ***/

@isTest
private class TestMyControllerExtension {
  
    static testMethod void TestMyControllerExtension() {
       
        ApexPages.StandardController stdController;
        MyControllerExtension mce = new MyControllerExtension(stdController);
       
        Opportunity oppor = mce.getOpportunity();
 
        oppor.StageName = 'Closed Won';
        oppor.Account.Region__c = 'UK';
         
    
        System.assertEquals(mce.getButtonState(),'False');

    }

}

 

 

Message Edited by jlim on 07-27-2009 02:49 PM
  • July 27, 2009
  • Like
  • 0

I got two objects 'Promotion' and 'Feedback'. Promotion has got a field called "isChanged" and Feedback has got a field called "Feedback body" which is of text area. The two objects are related by Id (Promotion Field) and promotion Id (Feedback Field)

 

I would like to write a trigger in such a way that whenever users changes the status of promotion to "Closed", there must be a predefined feedback text generated in the Feedback Body field.

 

The code which I have written is below. But this is not helping though am not getting any errors.

trigger StatusChange on Promotion (after update) 
 {
  for(Promotion i : Trigger.new)
  
  {
   if(i.isChanged == true)
    {
     String str = i.Id;
      Feedback ic = [Select FeedbackBody from Feedback where PromotionId = :str];
       ic.FeedbackBody = 'Staus has been changed';

    }
  }
 }
  • July 24, 2009
  • Like
  • 0