• alok29nov
  • NEWBIE
  • 205 Points
  • Member since 2007

  • Chatter
    Feed
  • 7
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 34
    Questions
  • 68
    Replies

I am using this formula

 

(TODAY() - Date_Mktg_Lead__c) - IF((LastActivityDate - Date_Mktg_Lead__c)> (Action_Taken_Date__c - Date_Mktg_Lead__c), (LastActivityDate - Date_Mktg_Lead__c), (Action_Taken_Date__c - Date_Mktg_Lead__c))

 

This Includes three date fields 

 

Date_Mktg_Lead__c

LastActivityDate

Action_Taken_Date__c 


This is working well if all the date fields are filled but if one of the field is blank it dosn't work. Please suggest....

Hi All,

 

I have a requirement where I want to lock Status of an opportunity if opportunity is 'Closed Lost'. In other words, If opportunity is lost, status shold not be allowed to change.

 

 

What is best possible way to do it. Please suggest.

 

 

Thanks,

Alok

Hi All,

 

I have some apex jobs which I need to run every week.Earlier,I used to run it through developer console but Now, I need to create unmanaged package for the apex jobs. So now my requirement is to automate it using apex classes.

 

Can anybody please provide me some code so that I can get started.

 

Thanks,

Alok

Hi All,

 

I have some batch jobs in my org. They are working fine. I faced some isuus when I created some validation rules for making some fields mandatory. I get errors for my test classes that there must be those mandatory fileds in test classes which have been made mandatory through validation rules. I am able to run batch jobs only when i deactivate those validation rules.

 

I think there must be some ways so that test classes are not imacted directly by validtaion rules else every time i create a validation rule I have to make changes in test classes.

 

Can anybody please suggest some remedy for this. 

Thanks in advance!

 

 

Regards,

Alok 

 

Hi All,

 

I have written two apex classes in sandbox. Code for both the classes are similar except  type being differnet. I have two types of opportunities ie. recurrig and non-recurring. So the only difference in code is for type of opportunity. Rest of the code is same for both the classes.They are working fine in sandbox. But when I deploy these to production, One class

works well but for the other I get an error saying "Attempt to derefernce a null object".

 

I am unable to understand why I am getting this error when it is working fine in sandbox .Can someone please give me some pointer/reason why I am getting this error and solution.

 

Thanks,

Alok

 

Hi,

 

I have written a class in sandbox and a test class for thye same. It has test coverage of 91%. When I move it to prodcution, Its coveareg gets reduced and shows only 68%. It is happening beacuase of salesforce shows comment lines and curly breckets as uncovered code which should not be the case.

 

Can anybody suggest why is this happening and what is the solution Or is it a bug?

 

Thanks,

Alokk

Hi All,

 

I am trying to deploy a class from sandbox to production. It has 100% test coverage in sandbox but When I deploy it to prodcution, I get the below error.

    Failed ( 1 )

API NameTypeLineColumnProblem
Deploy Error   Average test coverage across all Apex Classes and Triggers is 64%, at least 75% test coverage is required.
Can anyone please tell me why am I getting this error and how can I remove this error?
Thanks,
Alok

Hi All,

 

I have written a bulkified trigger and a test class for the same with 100% test coverage in sandbox. When I try to move it to Production, I get this error.

 

TestBC_AverageAmountNew.ideaBatchTest()Class291Failure Message: "System.LimitException: Too many SOQL queries: 101", Failure Stack Trace: "Trigger.BookingQuota: line 29, column 1"

 

The above class "TestBC_AverageAmountNew" has been written for a batch class. I am unable to move trigger from sandbox to production.

 

How can I rectify the problem? Please help.


 

Thanks,

Alok

 

Hi All,

 

I have written a trigger and a test class for that. Test coverage for the trigger is 100% in sandbox. When I try to move it to Production, I get this error.(Please note it is a  bulkified trigger.).

 

TestBC_AverageAmountNew.ideaBatchTest()Class291Failure Message: "System.LimitException: Too many SOQL queries: 101", Failure Stack Trace: "Trigger.BookingQuota: line 29, column 1"

 

The above class "TestBC_AverageAmountNew" has been written for a batch class.

I am unable to understand how is the trigger related to above test class and how can I remove the error.

 

Any help would be greatly appreciated.

 

Thanks,

Alok

Hi,

 

I have a requirement where I need to create an email template where i need to include a contact Owner merge field. When I use {!contact.ownerid} in my template, I don't get any  value. Can anybody answer this why is this happening.

 

Thanks,

Alok

Hi All,

 

 I have a requirement where I need to send a mail to some users when full data is exported through any report. Please let me know what approach should I follow and how can I start with.

 

Thanks in advance!

 ~Alok

Hi All,

 

I have a requirement where I need to send a mail to some users when full data is exported through any report.

Please let me know what approach should I follow and how can  I start with.

 

Thanks in advance!

 

~Alok

Hi All, I have written a batch class and am not getting the expected results. I have tried everything possible and could not find out where I am wrong with my logic. Let me explain the issue in detail and with an example. I have a sales executive John who has total 412 opportunities and number of won opportunities for him are 256. When i run the batch, What I get is three set of won opportunities i.e. 197, 18,41 total of these are exactly 256.

 

What i think is that the results i am getting this because the data is being passed into three batches and a batch gets processed and its gets updated then the next one and then the third one. But what is expected is that number of won opportunities field should be updated with 256 not with three different values i.e. all the opportunities get processed for one opportunity owner and then updated not for 1 batch at a time.

 

I would like to mention here that I am getting the expected results for the opportunities owners who have less 200 opportunities. Please suggest me what change I need to make so that I can get the expected result and what the mistake is.

 

Hi all,

 

I have two fields Average_Sales_Cycle__c and Booking_Date__c.

Average_Sales_Cycle__c        Number(18, 0)

Booking_Date__c                     Date

 

I want to add both these fields and get the added value as a date. I am querying these two fields in a btach apex and trying to add both like below.

 

Date BookingDate=opp1.Date_Opened__c+opp1.Average_Sales_Cycle__c

 

but getting an error "Date arithmetic expressions must use Integer or Long arguments at line 85 column 40".

 

How can I achieve this and I also want to compare the month of BookingDate against 1 to 12.

 

Please let me know how this can be achieved.

 

Thanks

~Alok

 

 

Hi All,

 

I have a requirement where I need to create a trigger which ensures an account having same name with same parent id can't be inserted.

 

Can somebody help  me with the code?

 

 

Thanks in advance!

 

~Alok

Hi All,

 

I have written a query which prevents from entring a duplicte account. I just want to add one more condition.

If parent account of the account being entered is same only then I want make sure that account is not the duplicate one. And if parent id is different then an account with same name can be entered.

 

My code is below:

 

trigger accDuplicatePreventer on Account (before insert, before update) {

Map<String, Account> accMap = new Map<String, Account>();

for (Account acc : System.Trigger.new) {

if ((acc.Name != null) &&  (System.Trigger.IsInsert || acc.Name!= System.Trigger.oldMap.get(acc.Id).Name)) {

if (accMap.containsKey(acc.Name)) {

  acc.Name.addError('Another new acconut has the ' + 'same email address.');

} else {

    accMap.put(acc.Name, acc); } }

}

for (Account acc : [SELECT Name FROM Account WHERE Name IN :accMap.KeySet()]) {     Account newAccount = accMap.get(acc.Name);     newAccount.Name.addError('A account with this name' + '  already exists.');

}}

 

 

How the above code can be modified to accomodate the above condition.

 

Thanks in advance!

 

~Alok

Hi All,

 

I have a requirement where I need to create  a formula field on opportunity object which reefrs to a custom object.

 

Let me explain it in detail. I have a custom object called Booking quota which has booking amount for different users/Opportunity owners. It is like below one.Let say there are three opportunity user A, B, C.

My object Booking Quota has details like this:

 

Booking Quota



(Opportunity Owner)         Amount



A                                          $100000

B                                          $120000

C                                          $180000

 

Now I have these different opportunity owners on opportunity page. I want to create a formula on opportunity object field let say Booking Amount which populates $100000 if opportunity owner is A and $120000 in case of B.

 

Please tell me how this can be achieved.

 

Thanks

~Alok

 

Hi All,

 

I have written a query where I want to update a field on opportunity if Opportunity Owner of any opportunity is changed. I have a field Previous_Owner__c on opportunity which stores the name of previous owner if owner is changed.

I am getting the below error:

"Apex trigger OpptyPreOwnAssn caused an unexpected exception, contact your administrator: OpptyPreOwnAssn: execution of BeforeUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 006P0000003XNGsIAO; first error: SELF_REFERENCE_FROM_TRIGGER, Object (id = 006P0000003XNGs) is currently in trigger OpptyPreOwnAssn, therefore it cannot recursively update itself".

 

 

trigger OpptyPreOwnAssn on Opportunity ( before update) {

     List <Opportunity> listOppty= [Select Id,OwnerID, Previous_Owner__c from Opportunity where Id In:Trigger.New];

    Set<ID> Owner1id = new Set<ID>();

   

    List<Opportunity> opp2= new List<opportunity>();      

       

     for(Opportunity opp1 : listOppty){                 

       Owner1id.add(opp1.OwnerId);   }  

 

     List< User > listusr = [Select Id,Name from User where ID in : Owner1id];         

 

  

for (ID id1:Owner1ID){     

 for (Opportunity opp:listOppty){                

   for (User usr:listusr){           

      if(opp.ownerid==usr.id){

                             opp.Previous_Owner__c=usr.Name;              

                             opp2.add(opp);                            

                     }}  }   }              

                 update opp2;              

  }

 

 

 

I am not able to figure out why I am getting the  error. Can anybody please suggest the remedy for the above.

 

Thanks

~Alok

Hi All,

 

I have a requirement where I need to create  a formula field on opportunity object which reefrs to other custom object.

 

Let me explain it in detail. I have a custom object called Booking quota which has booking amount for different users/Opportunity owners. It is like below one.Let say there are three opportunity user A, B, C.

My object Booking Quota has details like this:

 

Booking Quota



(Opportunity Owner)         Amount



A                                          $100000

B                                          $120000

C                                          $180000

 

Now I have these different opportunity owners on opportunity page. I want to create a formula on opportunity object field let say Booking Amount which populates $100000 if opportunity owner is A and $120000 in case of B.

 

Please tell me how this can be achieved.

 

Thanks

~Alok

Hi All,

 

I am trying to run a batsh class at regular intervals. I have writen below class but geting an error " expecting a right parentheses, found 'One'.

 

global class scheduledMerge10 implements Schedulable{

global void execute(SchedulableContext SC) {

AverageSpentDays b = new AverageSpentDays();

database.executebatch(b);
}
Schedulemerge10 b = new Schedulemerge10();
String sch = '0 0 7 07 12 ?';
system.schedule ('One', sch, b);

}

 

Is above the right way of writing a class for  scheduler?

 

~Alok

Hi All,

 

I have a requirement where I have to grade out some fields. Let me explain the requirement. I have a filed called "Stage' which has different stages like Stage A, Stage B, Stage C. These stages have some sub-stages like Stage A-Contact Made, Stage A-Goal Shared, Stage B-Contact Made, Stage B-Goal Shared, Stage B-Contact Made, Stage B-Goal Shared.

 

My requrement is when I select a  stage, Sub-satges of it should appear in other section or table with date fields against every sub stage and other stage should be graded out(user interface element should be  displayed with a light shade of gray instead of black).

 

What componetns are available in visualforce to grade out components while making some componetns appear in black and also some help on apex controler class.

 

Any code or pointer would be appreciated.

 

Thanks

~Alok

Hi All,

 

I have a requirement where I want to lock Status of an opportunity if opportunity is 'Closed Lost'. In other words, If opportunity is lost, status shold not be allowed to change.

 

 

What is best possible way to do it. Please suggest.

 

 

Thanks,

Alok

Hi,

 

I have a picklist which has one field 'Others'. I want to appear a text box just below the picklist if a user selects 'Others'.

How can I achieve that? Is there any way around except record types?

 

Thanks in advance!

 

Rgds,

Alok

  • October 09, 2012
  • Like
  • 0

Hi,

 

I want to generate a report for all open opportunities of 2012 till last week. Is there any way around so that I can achieve the same?

 

Thanks,

Alok

  • October 05, 2012
  • Like
  • 0

Hi All,

 

I have written a bulkified trigger and a test class for the same with 100% test coverage in sandbox. When I try to move it to Production, I get this error.

 

TestBC_AverageAmountNew.ideaBatchTest()Class291Failure Message: "System.LimitException: Too many SOQL queries: 101", Failure Stack Trace: "Trigger.BookingQuota: line 29, column 1"

 

The above class "TestBC_AverageAmountNew" has been written for a batch class. I am unable to move trigger from sandbox to production.

 

How can I rectify the problem? Please help.


 

Thanks,

Alok

 

Hi All,

 

I have written a trigger and a test class for that. Test coverage for the trigger is 100% in sandbox. When I try to move it to Production, I get this error.(Please note it is a  bulkified trigger.).

 

TestBC_AverageAmountNew.ideaBatchTest()Class291Failure Message: "System.LimitException: Too many SOQL queries: 101", Failure Stack Trace: "Trigger.BookingQuota: line 29, column 1"

 

The above class "TestBC_AverageAmountNew" has been written for a batch class.

I am unable to understand how is the trigger related to above test class and how can I remove the error.

 

Any help would be greatly appreciated.

 

Thanks,

Alok

Hi,

 

I am new to Apex and have following doubts, can you please answer?

 

  1. Can we invoke a Trigger from a class, if so an example please.
  2. Can we invoke a Class from a Trigger, if so an example please.

 

Thanks,

Sush.

Hi,

 

I have a requirement where I need to create an email template where i need to include a contact Owner merge field. When I use {!contact.ownerid} in my template, I don't get any  value. Can anybody answer this why is this happening.

 

Thanks,

Alok

Hi all,

 

What is the use of Trigger.OldMap and Trigger.NewMap?

 

Can you please give me solution

 

Thanks for your help

Hi All,

 

 I have a requirement where I need to send a mail to some users when full data is exported through any report. Please let me know what approach should I follow and how can I start with.

 

Thanks in advance!

 ~Alok


Hi,

I am still in process of learning APEX coding. However I need to do a Trigger urgently.

I wrote trigger with the help of a blog and it works great. Now, I need Test Method to deploy it in production.

Trigger:

trigger ownerCopy on Account(Before Insert, Before Update) {

    // handle arbitrary number of opps
    for(Account x : Trigger.New){

        // check that owner is a user (not a queue)
        if( ((String)x.OwnerId).substring(0,3) == '005' ){
            x.Owner_2__c = x.OwnerId;
        }
        else{
            // in case of Queue we clear out our copy field
            x.Owner_2__c = null;
        }
    }

}

I am trying myself using this documentation, however any help will be greatly appretiated.

Regards,

hai......... if u have any possible to check the values of rich text area is null or not in any standard or costom object?

I am using this formula

 

(TODAY() - Date_Mktg_Lead__c) - IF((LastActivityDate - Date_Mktg_Lead__c)> (Action_Taken_Date__c - Date_Mktg_Lead__c), (LastActivityDate - Date_Mktg_Lead__c), (Action_Taken_Date__c - Date_Mktg_Lead__c))

 

This Includes three date fields 

 

Date_Mktg_Lead__c

LastActivityDate

Action_Taken_Date__c 


This is working well if all the date fields are filled but if one of the field is blank it dosn't work. Please suggest....

Hi All,

 

I am not able to catch the below exception and it is being displayed on to the front end.

core.apexpages.exceptions.ApexPagesHandledException: INVALID_QUERY_LOCATOR: invalid query locator.

 

can you also let me know wat is the difference between Handled and Unhandled exception??

 

waiting your quick response.

 

Thanks,

Sridhar

Hello,

 

once we log into salesforce, click Your Name > Setup > Data Management > Data Loader.

 

Do you know the license of this software? I know it is free but we need to be sure about the license before we take it in our organization.

 

Could you please confirm that it is free.

 

regards

Vinay

99599465165

 

 

 

 

  • January 10, 2012
  • Like
  • 0

Hi,

I have a class in which I am updating a field for a custom object.For this class i have written a test class.In this test class i was creating new record for my custom object.

 

The problem is for this custom object,Name field is an Autonumber field.

So in my test class after inserting i was trying to send this Name to my Apex class.But surprisingly it is giving me NULL after insert in Test class.

 

Kindly let me know if this is a Salesforce defect.

 

Thanks,

Eswar.