• dip1.2925748739444993E12
  • NEWBIE
  • 0 Points
  • Member since 2011

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

Hi,

 

How to write a single test class for multiple trigger written in custom object?

 

Any suggestion will be helpful.

 

Thanks,

Hi,

 

I have wriiten a following trigger:

 

trigger UpdateAccountNameInBirthdayGiftList on Birthday_Gift_List__c(before insert, before update)
{
    List<string> lst_RepIDs = new List<string>();
    Map<String, Id> map_Accounts = new Map<String, Id>();
   
    for(Birthday_Gift_List__c bgl : Trigger.new)
    {
        lst_RepIDs.add(bgl.Rep_ID__c);
    }
   
    for(Account account : [  Select Id,
                                    AccountNumber
                               From Account
                              Where AccountNumber In :lst_RepIDs])
    {
        map_Accounts.put(account.AccountNumber , account.Id);
    }
   
    for(Birthday_Gift_List__c bgl : Trigger.new)
    {                          
        if(map_Accounts.containsKey(bgl.Rep_ID__c) == true)
        {
            bgl.Account__c = map_Accounts.get(bgl.Rep_ID__c);
        }
        else
        {
            //throw error ...
           
            bgl.addError('You can\'t insert this record!');
            return;
        }       
    }   
}

 

I have to write the tesat class for this trigger. How test class can be written for this trigger.

 

Any help will be appreciated.

 

Thanks, 

Hi,

 

I have to update the account lookup field in one of custom object (Receiving order) using triiger. the trigger will be based on rep id field value. for rep id field value account record id will be find out and then populate that record in to corresponding custom object record.

 

Any code will be helpful to me.

 

Thanks, 

Hi,

 

I have created a custom object called receiving order which has a lookup field account. When I go to insert a record in receiving order, i am unable to insert the lookup field value in account. How lookup field value can be inserted. I have no Account record Id. Any trigger code sample will be helpful.

 

Thanks.

Hi,

 

I am using salesforce connector to insert the record in custom object. During insertion of record some fields value is not inserted. Also, while i am going to update that field value it shows me error that Row Update Failed
Unable to create/update fields: Please check the security settings of this field and verify that it is read/write for your profile or permission set. I checked the security setting of that field. The security setting is correct.

 

What can be the reason so that some field values are neither inserted nor updated by excel connector.

 

Any help will be appreciated.

 

Thanks.

Hi,

 

I have written following test class:

 

trigger UpdateAccountNameInCase on Case (before insert, before update) 
{

//System.debug('\n ##### lst_Account @@@@ '+lst_Account.size());

for(Case c : Trigger.new) 
{
List<Account> lst_Account = [SELECT ID, Name, Account_Email__c FROM ACCOUNT where Account_Email__c =: c.SuppliedEmail limit 1];


    System.debug('\n ##### Loop -1 @@@@ ');
    
    for(Account a : lst_Account)
    {
    System.debug('\n ##### Loop -2 @@@@ ');
    if(c.SuppliedEmail != null && c.SuppliedEmail == a.Account_Email__c){   
    //a  = Database.query('select Account.name from Account limit 1');
    System.debug('\n ##### Loop -3 @@@@ '+c.SuppliedEmail+' and Account email -> '+a.Account_Email__c);
    c.AccountID = a.ID;
    }
    }
    
}
}

 

 

I want to write a test class for this trigger. I am new in writing test class.

 

Any help will be appreciated.

 

Thanks.

Hi,

 

I want to send an automatic email using trigger to sender when a case is created by email to case process in salesforce.

 

Any sample code will be helpful.

 

Thanks.

When I am going to merge two case records using trigger I am getting the following error: Compile Error: Specified type SOBJECT:Case cannot be merged

The triiger code is given below:

 

trigger CaseMergeTrigger on Case (before delete, after delete, after update) {
 
  for(Case c : Trigger.new) {
  List<Case> ls_Case = new List<Case>{new Case(Subject ='testing'),new Case(Subject ='testing2')};

  //List<Case> lst_Case = [SELECT CaseNumber, Subject FROM Case where Subject =:c.Subject];
insert ls_Case ;
Case masterCase = [SELECT CaseNumber, Subject FROM Case WHERE Subject = 'testing' LIMIT 1];
Case mergeCase = [SELECT CaseNumber, Subject FROM Case WHERE Subject = 'testing2' LIMIT 1];
merge masterCase mergeCase;
}
}

 

Please suggest where I am going wrong.

 

Thanks.

How can I merge two case record using trigger?

Any sample trigger code will be helpful.

 

Thanks & Regards,

Dipak Kumar Choudhary 

Hi,

 I want to update the account name lookup field in case record when a case is created from email to case process. The account name field is updated by using trigger. When email is sent case is created but account name field is not updated. The account name field is updated when case web mail is equal to account email(custom field). The trigger code is given below:

 

trigger UpdateAccountNameInCase on Case (before insert, before update)
{
List<Account> lst_Account = [SELECT ID, Name, Account_Email__c FROM ACCOUNT where Account_Email__c <> NULL limit 2];


//System.debug('\n ##### lst_Account @@@@ '+lst_Account.size());

for(Case c : Trigger.new)
{

    System.debug('\n ##### Loop -1 @@@@ ');
   
    for(Account a : lst_Account)
    {
    System.debug('\n ##### Loop -2 @@@@ ');
    if(c.SuppliedEmail != null && c.SuppliedEmail == a.Account_Email__c){  
    //a  = Database.query('select Account.name from Account limit 1');
    System.debug('\n ##### Loop -3 @@@@ '+c.SuppliedEmail+' and Account email -> '+a.Account_Email__c);
    c.Account = a;
    }
    }
   
}
}

 

Can anybody help on this. where I am missing anything?

 

 

I want to associate the Session Id returned from login() method with an External Webservice .

How do I associate this session id with SOAP Header for any subsequent API Call ?

Any code snippet will be useful.

Hi,

 

I have wriiten a following trigger:

 

trigger UpdateAccountNameInBirthdayGiftList on Birthday_Gift_List__c(before insert, before update)
{
    List<string> lst_RepIDs = new List<string>();
    Map<String, Id> map_Accounts = new Map<String, Id>();
   
    for(Birthday_Gift_List__c bgl : Trigger.new)
    {
        lst_RepIDs.add(bgl.Rep_ID__c);
    }
   
    for(Account account : [  Select Id,
                                    AccountNumber
                               From Account
                              Where AccountNumber In :lst_RepIDs])
    {
        map_Accounts.put(account.AccountNumber , account.Id);
    }
   
    for(Birthday_Gift_List__c bgl : Trigger.new)
    {                          
        if(map_Accounts.containsKey(bgl.Rep_ID__c) == true)
        {
            bgl.Account__c = map_Accounts.get(bgl.Rep_ID__c);
        }
        else
        {
            //throw error ...
           
            bgl.addError('You can\'t insert this record!');
            return;
        }       
    }   
}

 

I have to write the tesat class for this trigger. How test class can be written for this trigger.

 

Any help will be appreciated.

 

Thanks, 

Hi,

 

I want to send an automatic email using trigger to sender when a case is created by email to case process in salesforce.

 

Any sample code will be helpful.

 

Thanks.

How can I merge two case record using trigger?

Any sample trigger code will be helpful.

 

Thanks & Regards,

Dipak Kumar Choudhary