• reddy s 1
  • NEWBIE
  • 10 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 3
    Replies
Hi Everyone, 
I want to get the difference value in between the two dates with data type is Date and Text using formula field, and finally the difference of date value should be displayed in the formula field. Please helpme on this.
Hi,
From vs code,when  I am trying to authorize the saleforce org ,i am getting error like below.Can any one please help me on this error part.
 
Error :- Error authenticating with auth code due to: self signed certificate in certificate chain
This is most likely not an error with the Salesforce CLI. Please ensure all information is accurate and try again.


Thanks,
Reddy S.
Hi everyone, 
below is my trigger with test class,  i am unable to cover the error message.how to cover the error message can some one help me.

trigger dupAccount on Account (before insert) {
    for(Account a:Trigger.new){
        List<Account> acc=[select id,Name from Account where Name=:a.Name];
        if(acc.size() > 0){
           a.Name.addError('cant insert duplicate records');
        }
    }

}

Test Class:
---------------

@isTest
public class dupAccount_Test {
    @isTest 
    static void testme(){
        Account a1=new Account(Name='sam',First_Name__c='test',Last_Name__c='data');
        Account a2=new Account(Name='samm',First_Name__c='tests',Last_Name__c='dataa');
        Test.startTest();
        insert a1;
        insert a2; 
        a2.Name='sam';
        Update a2;
        Test.stopTest();
    }

}


Thanks In Advance,
Reddy.


 
Hi Everyone,
I want to update the account name field with account name+year in created date, if the records updated with name&year these records should not updated again and again only new records should update with name&year.

Facing issues with if condition, can you please help me out this along with test class.
Here is my code : 

public class batchAccountConUpdate implements database.Batchable<Sobject>{
    public database.QueryLocator start(database.BatchableContext bc){
        //fetch the Account record and its related Contact records 
     
          return database.getQueryLocator('select id,name,createdDate,(select id,name from Contacts) from Account');
    
    }
    public void execute(database.BatchableContext bc, List<Account> scope){
        List<Account> acc=new List<Account>();
        List<Contact> con=new List<Contact>();
        for(Account a:scope){
            //Converting DateTime to Date  method
            DateTime dt = a.CreatedDate;
            Date myDate = date.newinstance(dt.year(), dt.month(), dt.day());
            System.debug('My date is-----' + myDate);
            DateTime dt1 =a.CreatedDate;
            Date myDate1= dt1.date();
            System.debug('My date is-----' + myDate1);
          //  if(a.Name != a.Name+myDate1.year() && a.Name != a.Name+a.CreatedDate){
            if(a.Name.contains( myDate1.year() )){
                a.name=a.Name+myDate1.year();
                a.Description='Account name was Updated with the year in Created Date'; 
            acc.add(a);
            for(Contact c : a.contacts){
                c.FirstName=a.Name;
                c.LastName=c.Name;
                c.Department='through batch apex';
                con.add(c);
            }
             }
        }
        
         
        update acc;
        Update con;
    }
    public void finish(database.BatchableContext bc){
        system.debug('>>>>>>Finish');
    }
}
 

Thanks in Advance.

 
Hi Everyone, 
I want to get the difference value in between the two dates with data type is Date and Text using formula field, and finally the difference of date value should be displayed in the formula field. Please helpme on this.
Hi,
From vs code,when  I am trying to authorize the saleforce org ,i am getting error like below.Can any one please help me on this error part.
 
Error :- Error authenticating with auth code due to: self signed certificate in certificate chain
This is most likely not an error with the Salesforce CLI. Please ensure all information is accurate and try again.


Thanks,
Reddy S.