• Rajesh SFDC
  • NEWBIE
  • 40 Points
  • Member since 2013
  • Salesforce Developer
  • Infosys

  • Chatter
    Feed
  • 0
    Best Answers
  • 8
    Likes Received
  • 1
    Likes Given
  • 115
    Questions
  • 31
    Replies
Here,my requirements, i am created one apex trigger. i want to cal those apex trigger to custom button for Enable or disbale is it possiable ?
1.Here, i am created one scheduler apex class for Send bulk Emails  its call at every morning. suppose, i want to send bulk emails like a 10,000 records using schedular apex class, is it possiable ?

 
trigger HistoryTracking on Case (before update)
{
    Map<string, Schema.SobjectField> caseFields = Schema.SObjectType.Case.fields.getMap();
   
    case caseold=trigger.old[0];
    For (Case cs : Trigger.new)
    {
        for (string fieldName : caseFields.keySet())
        {
            if ( cs.get(fieldName) != Trigger.oldMap.get(cs.id).get(fieldName))
            {
              string oldvalue = string.valueOf(caseold.get(fieldName));
              string newvalue= string.valueOf(cs.get(fieldName));
             
              string parentoldvalue = string.valueOf(caseold.get('ParentId'));
              string parentnewvalue= string.valueOf(cs.get('ParentId'));
        
              if(fieldName != 'Description')
               cs.History_Tracking__c = 'Changed '+fieldName +' From '+oldvalue +' to '+ newvalue;   ------------->this line doen't  cover the code coverage
              else
                 cs.History_Tracking__c = 'Changed On Long Field' ; ------------->this line doen't  cover the code coverage
                
             if(parentoldvalue != null && parentnewvalue== null )
             {
                 cs.CheckParent__c='RemoveParent';   ------------>this line doen't  cover the code coverage
                 system.debug('______________checkparentid+++++++++++++++++++'+cs.CheckParent__c);
             }
             else if( parentnewvalue != null)
             {
                  cs.CheckParent__c='';
             }
                
                 break;
             }  }
    }}
test class
=============
@isTest(seeAllData=true)
private class Testcasehistory
{
    static testMethod void updatefields()
    {
        list<Case> cslist=new list<case>();
        case cs=new case();
        cs.Origin='Web';
        cs.Reason='other';
        cs.Priority='Medium';
        cs.Status='New';
        cs.Type='Other';
        cs.Subject='ESTDeveloper';
        cs.Priority='1 - Critical';
        cs.TFS_WorkItem_Type__c='Bug';
        cs.Description='changedSFDCTOTFS';
        cs.ParentId=cs.id;
       
         // System.assertEquals(cs.Description,' cs.History_Tracking__c');
          // cs.History_Tracking__c='Changed On Long Field';
       
           if(cs.ParentId == null)
           {
           cs.CheckParent__c='RemoveParent';
           }
           else if(cs.ParentId != null)
             {
           cs.CheckParent__c='';
            }
       // cs.Origin='Email';
        cslist.add(cs);
        test.startTest();
        insert cslist;
       
        cs.Origin='Email';
        update cslist;
        test.stopTest();
    }
}
here, my requirments whenever i am creating new records on case object, insert or update to custom object cases__C, suppose i want to delete records in case objects
that corresponding records delete in custom object cases__C.how to do ?

trigger CreateCases on Case (after insert,after update)
{

  Case cs=Trigger.new[0];
   Case csold=Trigger.old[0];
  if (Trigger.isInsert)
  {
     List<cases__C> caslist=new list<cases__C>();
     Cases__c ci=new Cases__c();
     ci.Case_Number1__c=cs.CaseNumber;
     ci.Origin__c=cs.Origin;
     ci.Priority__c=cs.Priority;
     ci.Status__c=cs.Status;
     ci.Type__c=cs.Type;
     ci.Description__c=cs.Description;
     ci.Subject__c=cs.Subject;
     ci.Reason__c=cs.Reason;
     insert ci;
     //calist.add(ci);
  }
  if(Trigger.isUpdate)
  {
  
    list <Cases__c> caupdate=new list<Cases__c>();  
    caupdate=[select id,Case_Number1__c,Origin__c,Priority__c,Status__c,Type__c,Description__c,Subject__c,Reason__c from Cases__c where Case_Number1__c =: cs.CaseNumber];
     integer si=caupdate.size();
     system.debug('-------------------'+si);
    
     for(Cases__c cx: caupdate)
     {
         cx.Case_Number1__c=cs.CaseNumber;
         cx.Origin__c=cs.Origin;
         cx.Priority__c=cs.Priority;
         cx.Status__c=cs.Status;
         cx.Type__c=cs.Type;
         cx.Description__c=cs.Description;
         cx.Subject__c=cs.Subject;
         cx.Reason__c=cs.Reason;
         update cx;
     }
   }
    Case csold=Trigger.old[0];
   if(Trigger.isDelete )
   {
  
    Cases__c casdel =new Cases__c();
     casdel =[select id,Case_Number1__c from Cases__c  where  Case_Number1__c =: csold.CaseNumber ];--------> delete records coding.
     if(casdel != NULL )
     {
      delete casdel;
      }
   }
  
}
here, i am generate the enterprise wsdl file and add webreference to TFS c# code

using c# code add automatically wsdl files to TFS is it possiabel? how to do
plz help me
here i want to fetch the case object for corresponding all attachments
using casenumber

public void getFilesfromSalesforce(string strCaseno)
{
        try
        {
            binding = new SforceService();
            lr = binding.login(strUserName, strpassword);
            loginResult = lr;
            //SforceService salesforce = new SforceService();
            binding.SessionHeaderValue = new SessionHeader();
            binding.SessionHeaderValue.sessionId = loginResult.sessionId;
            binding.Url = loginResult.serverUrl;
           
            QueryResult qResult = null;
            //Enterprise.Attachment at = new Enterprise.Attachment();
            //at.
         
         String soqlquery2 = "SELECT Id, CaseNumber,Status FROM Case  where CaseNumber =:"+ strCaseno;
         String soqlQuery = "Select Id, ParentId From Attachment where ParentId = " + soqlquery2.CaseNumber; here i am getting an error malformed query

            qResult = binding.query(soqlQuery);

           
        }
        catch (Exception ex)
        {

          
        }
here my requirments.. i want to get a files form attachments object from salesforce
                       using c# code.plz help me .
how to increase code coverage now i am geeting a 55% in apex trigger...
trigger test on Case (before update )
{
  Map<string, Schema.SobjectField> caseFields = Schema.SObjectType.Case.fields.getMap();

  case caseold=trigger.old[0];
  For (Case cs : Trigger.new)
  {
    for (string fieldName : caseFields.keySet())
     {
       
        if ( cs.get(fieldName) != Trigger.oldMap.get(cs.id).get(fieldName))
        {
           // cs.Track_status_history__c = 'Field ' + fieldName + ' changed from ' + string.valueOf(Trigger.oldMap.get(cs.id).get(fieldName)) + ' to '  +string.valueOf(cs.get(fieldName));
             string oldvalue = string.valueOf(caseold.get(fieldName));------------->doesnot executing
            
             string newvalue= string.valueOf(cs.get(fieldName));------------->doesnot executing
           
             cs.Track_status_history__c = 'Changed '+fieldName +' From '+oldvalue +' to '+ newvalue;
         
             break;
          }   
       }
  }
}
=============================================
@isTest
private class Testcasehistory
{

   static testMethod void updatefields()
    {
     list<Case> cslist=new list<case>();
     case cs=new case();
     cs.Origin='Web';
     cs.Reason='other';
     cs.Priority='Medium';
     cs.Status='New';
     cs.Type='Other';
     cslist.add(cs);
     test.startTest();
      insert cslist;
    
     Case updcase = [SELECT Id,Origin,Reason,Priority,Status,Type  FROM Case WHERE Id=:cs.Id];
     update updcase;
     test.stopTest();
    }
}=====================
iam getting an error :could not run tests on class because invalid type:baseConfigController
apex trigger:
===============================
trigger test on Case (before update )
{
  Map<string, Schema.SobjectField> caseFields = Schema.SObjectType.Case.fields.getMap();

  case caseold=trigger.old[0];
  For (Case cs : Trigger.new)
  {
    for (string fieldName : caseFields.keySet())
     {
       
        if ( cs.get(fieldName) != Trigger.oldMap.get(cs.id).get(fieldName))
        {
           // cs.Track_status_history__c = 'Field ' + fieldName + ' changed from ' + string.valueOf(Trigger.oldMap.get(cs.id).get(fieldName)) + ' to '  +string.valueOf(cs.get(fieldName));
             string oldvalue = string.valueOf(caseold.get(fieldName));
            
             string newvalue= string.valueOf(cs.get(fieldName));
           
             cs.Track_status_history__c = 'Changed '+fieldName +' From '+oldvalue +' to '+ newvalue;
         
             break;
          }   
       }
  }
}
================================test class============================================
@isTest
public class Test_casehistory
{

    public static testmethod void m1()
    {
     Case cs=new case();
     cs.Origin='Web';
     cs.Reason='other';
     cs.Priority='Medium';
     cs.Status='New';
     cs.Type='Other';

     test.startTest();
     list<case> lTest1=new list<case>();
     lTest1 = [SELECT Id,Origin,Reason,Priority,Status,Type  FROM Case WHERE Id=:cs.Id];
     update lTest1;
     test.stopTest();
    }
}
here my requirments i want to get whose last modified fileds values to update to case object
using apex trigger
here my code given below:
trigger TrackigHistory on Case (before update)
{

    set<Id> setId = new set<Id>();
    string strhistory;
   
     for(Case con: trigger.new)
     {
        setId.add(con.Id);
               List<CaseHistory> ch = [Select id,CaseId, Field, NewValue, OldValue from CaseHistory where CaseId = :setId  ];
      
         system.debug('&&&&&&&CaseHistory size&&&&&&&&&&'+ch.size());
       // for(integer i=0;i<ch.size();i++)
       for(CaseHistory c: ch)
        {
          // if(ch[i].Field != NULL && ch[i].OldValue != NULL && ch[i].NewValue != NULL)
           //{
                 system.debug('&&&&&&&CaseHistory&&&&&&&&& '+'Field '+c.Field +' Changed from ' +c.OldValue+' to ' +c.NewValue);
           
                 con.Track_status_history__c = 'Field '+c.Field +' Changed from ' +c.OldValue+' to ' +c.NewValue;
                 how to get fields values last modified field values updat to case object
           //}
        }
     
      }

  
               
 
}
here my requirments i want to get whose last modified fileds values to update to case object
using apex trigger
here my code given below:
trigger TrackigHistory on Case (before update)
{

    set<Id> setId = new set<Id>();
    string strhistory;
   
     for(Case con: trigger.new)
     {
        setId.add(con.Id);
               List<CaseHistory> ch = [Select id,CaseId, Field, NewValue, OldValue from CaseHistory where CaseId = :setId  ];
      
         system.debug('&&&&&&&CaseHistory size&&&&&&&&&&'+ch.size());
       // for(integer i=0;i<ch.size();i++)
       for(CaseHistory c: ch)
        {
          // if(ch[i].Field != NULL && ch[i].OldValue != NULL && ch[i].NewValue != NULL)
           //{
                 system.debug('&&&&&&&CaseHistory&&&&&&&&& '+'Field '+c.Field +' Changed from ' +c.OldValue+' to ' +c.NewValue);
           
                 con.Track_status_history__c = 'Field '+c.Field +' Changed from ' +c.OldValue+' to ' +c.NewValue;
                 how to get fields values last modified field values updat to case object
           //}
        }
     
      }

 } 
               
 

I have a requirement like, need to select multiple records on the list view. After done with the selection of records. If I click the List view custom button, those selected records must be created into another object. here my code giveb below
{!REQUIRESCRIPT('/soap/ajax/29.0/connection.js')}
var selectedLeads = {!GETRECORDIDS($ObjectType.Lead)}, index = 0; leads, newobjs = {}, newrec, saveresults;

if(selectedLeads[0]== NULL)
{
    alert("select a record atleast");
    return;
}

leads = sforce.connection.retrieve('Id,Name', 'Lead', selectedLeads);

while(index < leads.length)
{
    newrec = new sforce.SObject('position__c');

    newrec.candidate__c = leads[index].Name;

    newrec.job_description__c = leads[index].Name;

    newobjs.push(newrec);

    index += 1;
}
saveresults = sforce.connection.create(newobjs);
error: lead is not defined 

Junior Salesforce Administrator (201/301 certifications in progress) with Sales & Talent Acquisition/Staffing background seeking experience by offering my time and skills, for assistance in administering/maintaining Salesforce implementation locally (Seattle/Puget Sound) or via telecommute nationwide. I am offering 20 hours per week of my time. I am willing to travel as necessary where internet-based collaboration is not sufficient if the client carries the expense. Highly interested in Start-up endeavors or short term projects allowing me to deepen my understanding of existing skills, including but not limited to:

Creation of Custom objects, tabs, fields

Creation and configuration of users

Customization of reports, dashboards optimizing metrics and analytics in support of the business

Data Migration using import wizard and data loader, Mapping, Cleaning Data, Error Validations, Backup Logs

Customized Date Validation Rules, Contact Validation Rules, User, Role, Profile Validation Rules, Cross Object Validation Rules, Opportunity Management Validation Rules, Address Verification Validation Rules

Customized OW permission, sharing rules, user profiles, permission sets, role hierarchies and field level security

Customized and created business workflow rules, and approval processes

Master/Detail relationships

Custom tailored page layouts and record types based on business processes

 

Please contact me to discuss further:

Anouk Siegert

AnoukS1208@gmail.com