• @anilbathula@
  • PRO
  • 2960 Points
  • Member since 2011

  • Chatter
    Feed
  • 99
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 20
    Questions
  • 519
    Replies
While deploying Workflow Email alert showing error as User doesn;t exist in target Org. How to resolve this error?
I need to tweak the code to any Task that contains the word Pardot will be deleted. I'm not a developer so any assistance will be appreciated. Thanks so much. 

Apex Class
public class TaskDeleteBatch implements Database.Batchable<sObject>{
    public Database.QueryLocator start(Database.BatchableContext bc){
      String query ='select id from task where createdby.Name =\'B2BMA Integration\' AND Subject LIKE \'Pardot List Email%\'';
        return Database.getQueryLocator(query);
    }
    public void execute(Database.BatchableContext bc, list<Task> scope){
        Database.delete(scope);  }
     public void finish(Database.BatchableContext bc)   }}

TaskDeleteBatchTest
@isTest public class TaskDeleteBatchTest {
    @isTest static void testMethod1(){
       Lead l = new lead();
        l.LastName = 'Test';
        l.Company = 'Test Company';
        l.How_did_lead_hear_about_us__c='Email Campaign';
        Insert l;
        
        Profile p = [SELECT Id FROM Profile WHERE Name='B2BMA Integration User']; 

        User u = new User(Alias = 'standt', Email='standarduser@leopardsolutions.com', 
                          EmailEncodingKey='UTF-8', LastName='B2BMA Integration', LanguageLocaleKey='en_US', 
                          LocaleSidKey='en_US', ProfileId = p.Id, 
                          TimeZoneSidKey='America/Los_Angeles', UserName='b2bmaintegration@leopardsolutions.com');
        
        system.runAs(u){
            Task t = new Task();
            t.Subject = 'Pardot List Email';
            t.whoId = l.Id;
            Insert t;   
            
            system.debug([select id,createdBy.Name from task][0].createdBy.Name);
        }
        
        Test.startTest();
          Database.executeBatch(new TaskDeleteBatch());
    Test.stopTest();

    }
}
global class TeacherBonusClass implements database.Batchable<sObject>, Database.Stateful{
    
    
    global Integer recordsProcessed = 0;
    
    
    global static Database.QueryLocator start(Database.BatchableContext bc){
        return Database.getQueryLocator('Select Name, Salary__c from Teacher__c');
    }
    
    global static void execute(Database.BatchableContext bc, List<Teacher__c> teaList){
        
        List<Teacher__c> teaNewList = new List<Teacher__c>();
        for(Teacher__c tea: teaList){
            if(tea.Salary__c< 300000){
                tea.Salary__c = tea.Salary__c + (0.002 * tea.Salary__c);
                teaNewList.add(tea);
                
            }
            recordsProcessed = recordsProcessed + 1;
        }
        insert teaNewList;
        
    }
    
    global static void finish(Database.BatchableContext bc){
        
        Messaging.SingleEmailMessage  mail = new Messaging.SingleEmailMessage();
        string[] toAddresses = new String[] {'akshattiwari489@gmail.com'};
        mail.setSubject('Salary Bonus Alert');
        mail.setToAddresses(toAddresses);
        mail.setPlainTextBody('Your Salary Has been Incremented  by 0.2% and your new salary is');
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
        
        
        
        
    }

}

I am trying to maintain states accross the transaction and I am getting error " Variable Does Not Exist: recordsProcessed " when I am tring to store values inside the recordsProcessed inside for loop. What modifications should I make in the code?
Hi,
I'm new in apex and need some help,


I write a trigger that creates a new account every time that I created an account:
trigger AccountParent on Account (after insert) {
    
    List<Account> acc = new List<Account>();
    
    for (Account a : Trigger.new) {
        Account ac = new Account();
        ac.Name = a.Description;
        ac.Parent__c = a.Name;
        acc.add(ac);
    }
    
    if (acc.size()>0) {
        insert acc;
    }
}

but when i create account i get an error:
AccountParent: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AccountParent: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Name]: [Name] Trigger.AccountParent: line 13, column 1: [] Trigger.AccountParent: line 13, column 1

why?? 
 

Hello everyone,

i have two objects name doctor and Appointment Doctor is parent object and Appointment is Child (Master Detail Relationship) in doctor object there is available Field(checkbox) ,when i create appointment if doctor is not availabel then appointment with that doctor Should not be schedule  so how can i validate Appointment Object Using Admin Knowledge.

 

 

Can I have help writing a query for permission set license holder in Salesforce. I am trying to find all the users who are assigned the permission set license named: Sales Cloud Einstein. 
Can someone tell me what am I doing wrong with the following formula? The formula hasn´t a sintaxis error, but, I´m not getting a percentage as answer,, Im getting 0.

if( text(Status)="Baja",0,

if(and(text(Ciclo__c )= "Fall 2020", (OwnerId)="Brenda Monzalvo"),1/35,

0))
SOQL Query:
SELECT ClaimNumber__c, Program__c, ProgramDesc__C , ClaimStartDate__c, ClaimEndDate__c
FROM ClaimHeader__x WHERE (ClaimNumber__c = '13128E' AND  ProgramDesc__c = 'STAR') OR (ClaimNumber__c = '13128E' AND ProgramDesc__c = 'CHIP')  ORDER BY ClaimStartDate__c DESC LIMIT 11 OFFSET 0
                
We are expecting only one record for this query with claim number '13128E', but it is returning more records.
 
Hi,
I've inherited a Sales Cloud org, that until recently had the following trigger working. Now the Original Total Cost is no longer populated at the trigger points.
However the Error at deletion is still being sucessfuly fired.
 
trigger OLITrigger on OpportunityLineItem (before insert, before update, before delete) {
    
 //Code block to enable bypassing of triggers using field off users record  
    String currentUserId = UserInfo.getUserId();
    User currentUser = [SELECT Bypass_Triggers__c FROM User WHERE Id = :currentUserId LIMIT 1];
    if (currentUser.Bypass_Triggers__c) return;
        
    If(System.Trigger.isInsert){
    
      For(OpportunityLineItem oli: Trigger.New){
    
        oli.Original_Total_Cost__c = oli.TotalPrice;
        
      }
  }
    
  If(System.Trigger.isUpdate){

       For(OpportunityLineItem oli : [SELECT TotalPrice,Original_Total_Cost__c,Opportunity.StageName FROM OpportunityLineItem Where Id IN: Trigger.New]){
           
      if(oli.Opportunity.StageName == 'Closed Won')
     {
         //Do Nothing
     }
           
      else  if(Trigger.oldmap.get(oli.id).TotalPrice == Trigger.newmap.get(oli.id).TotalPrice)
           {
               // Do nothing  
            }
                  
     else if(Trigger.oldmap.get(oli.id).TotalPrice != Trigger.newmap.get(oli.id).TotalPrice)
     {
          oli.Original_Total_Cost__c = Trigger.oldmap.get(oli.id).TotalPrice;
     }
       }
  }
       
  If(System.Trigger.isBefore &&System.Trigger.isDelete){
    
  For(OpportunityLineItem oli : Trigger.old)
    {
        if(oli.number_of_invoice_lines__c == 0 || oli.number_of_invoice_lines__c == null){

        list<Line_Item_Details__c> LineItemDetailsId=[Select Id FROM Line_Item_Details__c Where id =:oli.Line_Item_Details__c];     
        delete LineItemDetailsId;
        }
        
        else if(oli.number_of_invoice_lines__c >= 1) 
        {
            oli.addError('You can not delete this Product as it has Invoiced Schedules');
        }
       
    }
    }

}

 
 for(Lead l: scope)
        {
            
            if(l.State!=''){ //State is not empty
                l.State__c =l.State__c;
            }else{    //State is empty
                l.State__c ='Default';}
            
            
            l.Age__c = l.Current_Age__c;
            
        }
        update scope;
    }

Hi all,

In platform developer II there are 65 questions and 5 of them do not account for the exam percentage they have zero marks. Can somebody tell me if they are the last 5 questions? or they appear randomly.

Thanks,

A

Hello,

I am wondering exactly what happens when you 'cancel' a DX command run in VSCode using the button in the UI, e.g.:

Screenshot of SFDX in VSCode

If it is DEPLOYING changes - will it revert any changes already made? Could it be possible that some of the changes may have already been applied to an org?


Hoping someone can answer for me. Cheers
 
Hello,

What is the SOQL query to check the list of thins a user is following.
The user can click Follow on Account, Opportunity etc
but is there any limit on thiings to follow
Hi friends,
I'm trying to deploy source to org with Visual Studio Code, but I get this error: Invalid version specified:47.0
How Can I fix it?
INFO:
1. my org is a developer edition
2. my apex api version is 46.0
3. I already run sfdx force:config:set apiVersion=46.0 --global (in VS Code)
4. my VS Code plugins versions is:
salesforcedx 47.0.7 (pre-release)
├─ force-language-services 47.0.2
└─ salesforce-alm 47.0.7
Please, help me. Thank you.
I have an excellent trigger (inherited from the previous SFDC Admin) that pulls in values from a custom object that manages my territories by zip code. I'm rolling out Salesforce for my European team and unfortunately the zip codes in Germany are duplicates to zip codes in the US. 

How do I update the trigger to prevent it from firing if the Country is not USA? I am using standard country and state picklists.