• SFDC 2017
  • NEWBIE
  • 38 Points
  • Member since 2014
  • Salesforce Developer

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 36
    Questions
  • 32
    Replies
Is there any way to read data from excel or fetch data from excel and those records need to delete using apex .I know we can use data loader but for big objects dataloader is not possible so i am in need of doing it by fetching data from excel and delete using apex.

Any suggestion please
Hi All,

I have written a batch apex in a such a way that if string field we are passing then in query it should take other wise no.It is working for single string value but i need to make it work for multiple string values.

Constructor:
global StateBatch(String strfield,Date startDate, Date enddate) {
        
        if(StartDate!= null && Enddate!= null){
            query = 'select Id,Status_vod__c from State__c where Start_Date__c >=:startDate AND End_Date__c<=:endate';
            if(String.isNotBlank(strfield)){
               query += ' AND State__c IN (:strfield)' ;
            }
        }
    } 

Running in DEv console as 
for multiple markets you run it as 
StateBatch sb = new Statebatch ('\'United States of America\',\'United Kingdom\'',Date.newInstance(2019, 02, 13),Date.newInstance(2019, 02, 14)); 
database.executeBatch(sb);
Multiple values it is not taking .How will change to support multiple values.

Thanks in Advance
Hi All,

I need a help regarding Custom Settings.In Contact we have fields like Firstname,lastname,Email,City etc.So i will store this specified fields in a custom settings (because in future these fields may be change so storing in custom setting )So whenever only this specified field values are updated in contact then only i need to create a record into another object .If other fields are updated it shouldnot trigger.I am not sure how to compare these field changes through Custom Settings and object Contact.

Anyone can give me some idea to get this scenario done.

Thanks in advance
Hi All,

We have ae afterinsertupdate trigger and we are calling handler class for that .Since we want the Id field of the lead so we used after insert and after update but now test class is failing with the below error:
System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, LeadTrigger: execution of AfterInsert

caused by: System.FinalException: Record is read-only.
Stack TraceClass:LeadAssignmentUtilTest.testLeadAssignment1: line 39, column 1
 private static testMethod void testLeadAssignment1() {
        createTestData();
        Test.startTest();
            insert testLead;
            Lead updatedLead = [SELECT Id, OwnerId FROM Lead WHERE ID =: testLead.Id LIMIT 1];
            system.assertEquals(updatedLead.OwnerId, standardUser.Id);
        Test.stopTest();
    }
I can,t change this to before insert because we need id of the Lead.some one please help me this is little urgent.

Thanks in advance,
 
Hi All,

I have written a batch class with the below scenario.
if (ObjectName==Account)
{ need to query account  records
}
else if (ObjectName =Contact )
{ Query Contact records)
}
So i will get either account or contact records in scope and in execute method i will create records for other custom object means if it is account it will insert with account Id in the new custom object and if Contact contact Id in the new object .Right now it is captuirng the Id into another custom Object but the problem is whenever i am executing it is capturing the same .

So here i want to eliminate the creation of duplicates means if the Record Id(Acc or con Id already in the new custom object then it should not create new record if the record is not existing then create new record with the Acc or Con Id

My Code:
  global void execute(Database.BatchableContext BC, List<SObject> scope)
    { 
        Map<id, Custom Object> CustomMap= new Map<id,Custom Map>();
         for(Sobject obj: scope)
         {      
                Custom Object cm= new Custom Object();
                 
                 cm.Recordt_ID__c =obj.Id;
                 
                  CustomMap.put(Cm.Object_ID__c, cm);
             
          }
          if(!CustomMap.isEmpty())
        {
            Database.SaveResult[] InsertResult = Database.insert(CustomMap.values(),false);
            
        }
        
    }

So here how i will check if there is already a record with same Object Id is there then it should not insert if it is not there it should create new custom object Record.Any one please guide how to do this

Thanks in advance
Hi All,  I used batch Apex normally but using dynamic apex i am new.Can anyone please guide me for the Following Scenario using Batch Apex(Dynamic)
 In Batch Class constructor: global Account batch(String ObjectName)  
My scenario i passed this ObjectName as parameter and
if (ObjectName==Account)
{ need to query account  records
}
else if (ObjectName =Contact )
{ Query Contact records)
}
So i will get either account or contact records in scope and in execute method i will create records for other custom object based on this scope And in scheduler class how i will pass for account and contact  
Please anyone guide me to do this  
Thanks in advance
Hi All,

I am working on one scenario where there are Multiple Child Records for eg:Account is a parent and Under Account multiple child Objects Records will be there.In that child Object i have created one checkbox field called Primary and first record should be primary and if users adding another record as primary it has to thrwo error Message there is already one primary Record please unselect the existing record and add new record as primary marked
Eg:Let say under account 3 child records are there and 1 is primary already and user is trying to add the 3 rd record as primary it should throw error Message
NEXT There are 3 Multiple Child Records and one is primary among them and user is trying to delete the primary record without marking any other records as primary then it should throw error Message as User is trying to Delete primary Record without making another primary
If there is only one primary and user is trying to delete then it should allow the user to delete.
Note :Child Record Refers to Contact 
Any one please guide me to help to implement this scenarios.
Hi All,
    I have two Custom Objects A and B with Master Detail Relationship.We have written one trigger with Before Insert and Before update Trigger for auto populating A field in B Object based on Five conditions .Trigger is working fine.But when we Upload Bulk records of Achievements through Data Loader nearly 40 k Records some are updating the Target Field and some of them are not updating.Some records won't match the conditions thats is fine but some records of Achievements if i update manually it is populating.We checked by reducing the Batch Size also still not resolved.Can any one help on this issue as soon as possible.I am posting the code as well can anyone help me on this trigger to make work for bulk Records also...

trigger populateAfield on ObjectB(before insert,before Update) 
{
   set<id> userids =new set<id>();
   set<id> accids =new set<id>();
   set<string> plant=new set<string>();
   set<string>rgn=new set<string>();
   set<string> compont=new set<string>();
   set<integer> Month =new set<integer>();
   set<Decimal> invceamt = new set<Decimal>();
   
   Map<id,ObjectA> mpA = new map<id,ObjectA>();
   
     forObjectB ac :trigger.new)
     {
         /*if(ac.User__c!=Null)
         {
            userids.add(ac.User__c); 
         }*/
         if(ac.Account__c!=null)
         {
             accids.add(ac.Account__c);
         }
         if(ac.Plant__c!=null)
         {
             plant.add(ac.Plant__c); 
         }
         
         if(ac.Component__c!=Null)
         {
             compont.add(ac.Component__c);
         }
         
         if(ac.Invoice_Date__c!=null)
         {
           month.add(ac.Invoice_Date__c.Month());
         }
         if(ac.Region__c!=null)
         {
            rgn.add(ac.Region__c); 
         }
        
     }
     
  List<ObjectA>A = [select id,OwnerId,Name,Account__c,Component__c,Plant__c,Region__c,
        Target_Amount__c,Target_Date__c,User_Name__c from A Where Region__c IN:rgn  AND CALENDAR_MONTH(Invoice_Date__c) IN :month AND 
                   Account__c IN:accids AND Component__c IN:compont AND Plant__c
                   IN :plant   
                  //AND User_Name__c IN :userids
                   ]; 
                       
         if(A!=null)
         {
              for(ObjectA  t:A )
              {
                   mpA .put(t.Account__c,t); 
                   system.Debug('@@@@@@@@@@@@@@@@@@@@@@@'+mpA);
              } 
         } 
         
        if((mpA .Size()>0))
           { 
        for(ObjectB ach:Trigger.New)
          {
          if(ach.Account__c!=Null)
          {
              if(mpA .get(ach.Account__c)!=Null)
              {
         Integer acmonth=ach.Invoice_Date__c.Month();
          Integer tarmonth=mpA .get(ach.Account__c).Invoice_Date__c.Month();
               if((ach.Account__c==mpA .get(ach.Account__c).Account__c)&&(ach.Component__c==mpA .get(ach.Account__c).Component__c)&&
                  (ach.Region__c==mpA .get(ach.Account__c).Region__c)&&(acmonth==tarmonth)&&
                  (ach.Plant__c==mpA .get(ach.Account__c).Plant__c))                       
                  {
                                  
                   ach.Target__c = mpA .get(ach.Account__c).id;  
                                        
                  }
               }
           }
       } 
       }  
      
                                                                
}



Thanks in advance...!!!
Hello,

I'm trying to complete the "Using Formula Fields" section in trailhead.
The task is:

For easier reporting and filtering, create a new custom formula field on the standard account object which looks at the SLA Expiration Date field and returns true if the current date comes after it. Otherwise, it should return false.The account object should have a custom date field with the Field Label 'SLA Expiration Date' and Field Name of 'SLAExpirationDate'. The resulting API Name should be 'SLAExpirationDate__c'. On a Developer Edition, the 'SLA Expiration Date' field may already exist.
The new formula field should have the Field Label 'SLA Expired' and Field Name of 'SLA_Expired'. The resulting API Name should be 'SLA_Expired__c'.
The formula field should be of type 'Checkbox'.
The formula field should calculate its response based on the current date.
The formula field should return true if the SLA has expired, and false if it has not.


My syntax is: SLA_Expiration_Date__c < Today()

The error message I am receiving is: 
Challenge not yet complete... here's what's wrong: 
There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: LUVRAIPP


Any help is appreciated.
 
Hai All,
I am facing a Problem while deploying Trigger into Production.I am Facing the below error while deploying:

Error Message
testAccountHierarchy testAccountHierarchy System.Exception: Apex CPU time limit exceeded
Stack Trace: Class.InlineAcountHerachy_TestUtilities.checkObjectCrud: line 39, column 1 Class.InlineAcountHerachy_TestUtilities.updateAccountList: line 101, column 1 Class.AccountHierarchyTestData.createTestHierarchy: line 33, column 1 Class.testAccountHierarchy.testAccountHierarchy: line 6, column 1.

This is because of a Class .InlineAcountHerachy_TestUtilities that we installed from Appexchange developed by Force.com Labs.
This is the name of the app Inline Account Hierarchy, please find the link
https://appexchange.salesforce.com/listingDetail?listingId=a0N300000016chCEAQ.

Please anyone help me on this issue and tell me how to resolve this quickly because this is little bit urgent .Because of this i am  not able to share Accounts .

I am attaching the scrrenshot of the Error Message for reference.

User-added image
Hi All,
  My scenario is I want custom Dupecatcher functionality for Contact Object using Trigger.For that condition Account is having two types of Recordtypes.Company and Person .So i created a formula field in Contact for getting that Account Recordtype in contact level.so based on that formula field i created in contact it should check duplicates.Because the  email and mobile which they are  having in Person will be replicted in Company contacts also but it will not replicate in Person contatc types.Which means email and mobile in Person Contacts will also be in Company contacts but willnot be again in Person Contacts.


Can any one suggest me for writing trigger for this Scenario.



Hi All

I have a custom object for RFPs.  What I need is when sales submits the RFP for pricing I need the owner of that record to round robine evenly between 3 people.

Step 1 - The sales rep fills out the RFP information and then changes the status to Submitted. 
Step 2 - I now want this to round robin evenly between 3 other employees

Its a pretty simple I think it can be done with a few workflows and field updates just not sure how

thank you in advance for your help

Hi everyone,

 

    I am a newbie to FDC (so please correct me if I am wrong anywhere) . I have gone thorugh Apex REST API and found that we can create our custom web services in Apex and expose them as REST services using Apex REST. But in most of the references it is given that we can use any programming language of our choice ( i.e. from outside FDC) to invoke this custom WS via REST API. But I want to invoke the same using Apex code (i.e., from inside FDC) via REST API.

 

Any help is highly appreciated