• Nishan
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 13
    Questions
  • 31
    Replies

Hi everyone,

                      I have to insert birthday events for a custom object called Mason__c. My code is not working. Can someone point out the mistake ? Thanks in advance

trigger BirthDayEvent on Mason__c (before update) 
{
	
    List<Event> eventList = new List<Event>();

	
	for(Mason__c mason :trigger.new)
	 {
	 	if(mason.Date_Of_Birth1__c != null)
	 	{     
	 		  decimal monthint =  mason.Date_Of_Birth1__c.month();
	 		  string monthstr;
	 		  if(monthint == 1)
	 		  monthstr = 'January';
	 		  else if(monthint == 2)
	 		  monthstr = 'February';
	 		  else if(monthint == 3)
	 		  monthstr = 'March';
	 		  else if(monthint == 4)
	 		  monthstr = 'April';
	 		  else if(monthint == 5)
	 		  monthstr = 'May';
	 		  else if(monthint == 6)
	 		  monthstr = 'June';
	 		  else if(monthint == 7)
	 		  monthstr = 'July';
	 		  else if(monthint == 8)
	 		  monthstr = 'August';
	 		  else if(monthint == 9)
	 		  monthstr = 'September';
	 		  else if(monthint == 10)
	 		  monthstr = 'October';
	 		  else if(monthint == 11)
	 		  monthstr = 'November';
	 		  else if(monthint == 12)
	 		  monthstr = 'December';
	 		  
	 		  
	 		  Event event = new Event();
	 		  date dt;
              dt=date.parse('01/1/2025');
              event.Subject ='Birthday ' + mason.Child_Name_1__c;
              event.startdatetime=mason.Date_Of_Birth1__c;
              event.enddatetime=mason.Date_Of_Birth1__c;
              event.OwnerId = UserInfo.getUserId();
              event.WhatId = mason.Id;
              event.ISRECURRENCE=true;
              event.RECURRENCETYPE='RecursYearly';
           	  event.RECURRENCESTARTDATETIME= mason.Date_Of_Birth1__c;
			  event.RECURRENCEENDDATEONLY=dt;
			  event.RecurrenceMonthOfYear = monthstr;
			  event.RecurrenceDayOfMonth = mason.Date_Of_Birth1__c.day();
              event.IsReminderSet = true;
              event.ReminderDateTime = DateTime.now().addDays(-2);
              eventList.add(event);
              
          }


        }


           if(eventList.size()>0)
           {
           insert eventList;
           }
           

}

 

  • November 28, 2013
  • Like
  • 0

Hi Everyone,

                      How can I add an event for a current custom object (not just a calender event) ?

trigger SiteEvent on Site__c (after insert, after update) 
  {
    List<Event> eventList = new List<Event>();
    
      for(Site__c site : Trigger.new)
        { 
          if(site.Date_Of_Next_Level_Of_Construction__c != null)
          {
              Event event = new Event();
              event.Subject = site.Name;
              event.StartDateTime = site.Date_Of_Next_Level_Of_Construction__c;
              event.EndDateTime = site.Date_Of_Next_Level_Of_Construction__c;
              event.OwnerId = UserInfo.getUserId();
              event.IsReminderSet = true;
              event.ReminderDateTime = site.Date_Of_Next_Level_Of_Construction__c;
              
              eventList.add(event);
              
          }
        }
           if(eventList.size()>0)
           {
           insert eventList;
           }
    }

 What I want is to insert this event in the current site record itself(trigger.new)

 

Thanks in advance

  • November 23, 2013
  • Like
  • 0

Hi Everyone,

                      I have a javascript button to update certain number fields. It is compiling without errors but not working. Can someone please help me with this

{!requireScript("/soap/ajax/26.0/connection.js")}

var input=prompt("Enter the number");
var query1 = sforce.connection.query("SELECT Id,Number_Added1__c,Number_Added2__c,Number_Added3__c,Number_Added4__c, Number_Added5__c, Number_Added6__c,Number_Added7__c,Number_Added8__c,Number_Added9__c,Number_Added10__c FROM Inventory__c WHERE Id='{!Inventory__c.Id}'");

var records = query1.getArray("records");

var inv = new sforce.SObject("Inventory__c");
inv.Id = "{!Inventory__c.Id}";


if (records[0].Number_Added10__c)
{
window.alert('All 10 slots are full for Stock A. Create the same item with an index name');
}

else if(!records[0].Number_Added1__c)
{
inv.Number_Added1__c = parseFloat(input);
inv.Remaining_Stock__c = records[0].Reamining_Stock__c + parseFloat(input);
}

else if(!records[0].Number_Added2__c)
{ inv.Number_Added2__c = parseFloat(input);
inv.Remaining_Stock__c = records[0].Reamining_Stock__c + parseFloat(input);
}

else if(!records[0].Number_Added3__c)
{ inv.Number_AddedB3__c = parseFloat(input);
inv.Remaining_Stock__c = records[0].Reamining_Stock__c + parseFloat(input);
}

else if(!records[0].Number_Added4__c)
{ inv.Number_Added4__c = parseFloat(input);
inv.Remaining_Stock__c = records[0].Reamining_Stock__c + parseFloat(input);
}

else if(!records[0].Number_Added5__c)
{ inv.Number_Added5__c = parseFloat(input);
inv.Remaining_Stock__c = records[0].Reamining_Stock__c + parseFloat(input);
}

else if(!records[0].Number_Added6__c)
{ inv.Number_Added6__c = parseFloat(input);
inv.Remaining_Stock__c = records[0].Reamining_Stock__c + parseFloat(input);
}

else if(!records[0].Number_Added7__c)
{ inv.Number_Added7__c = parseFloat(input);
inv.Remaining_Stock__c = records[0].Reamining_Stock__c + parseFloat(input);
}

else if(!records[0].Number_Added8__c)
{ inv.Number_Added8__c = parseFloat(input);
inv.Remaining_Stock__c = records[0].Reamining_Stock__c + parseFloat(input);
}

else if(!records[0].Number_Added9__c)
{ inv.Number_Added9__c = parseFloat(input);
inv.Remaining_Stock__c = records[0].Reamining_Stock__c + parseFloat(input);
}

else if(!records[0].Number_Added10__c)
{ inv.Number_Added10__c = parseFloat(input);
inv.Remaining_Stock__c = records[0].Reamining_Stock__c + parseFloat(input);
}


result = sforce.connection.update([inv]);

if(result[0].success == 'true')
{
window.alert('Stock successfully added to Stock A');
}
location.reload();

 

  • October 12, 2013
  • Like
  • 0

Hi everyone,

                     I have a code to update a certain object called Field_Executive based on another object called inventory. It is working fine when the lookup field to FE is filled. Here is the code

trigger FEupdate on Inventory__c (before update) 
 {
   for(Inventory__c inv : trigger.new)
    {    
         Inventory__c oldValue = Trigger.oldMap.get(inv.ID);
         Decimal noOfItems = oldValue.Remaining_Stock__c - inv.Remaining_Stock__c;
         
       Id feId = inv.Field_Executive__c;
       List<Field_Executive__c> fe = [Select Id, Item1__c, Item2__c, Item3__c, No1__c, No2__c, No3__c
                                      From Field_Executive__c where Id =:feId ];  
     
     if( noOfItems != 0 && !fe.isEmpty() )
      {
       String itemname = inv.Name;
       
       if(fe[0].Item1__c != itemname && fe[0].Item2__c != itemname && fe[0].Item3__c != itemname )
          {
             if(fe[0].Item1__c == null)
              {
               fe[0].Item1__c = itemname;
               fe[0].No1__c = noOfItems;
              }

             else if(fe[0].Item2__c == null)
              {
               fe[0].Item2__c = itemname;
               fe[0].No2__c = noOfItems;
              }

             else if(fe[0].Item3__c == null)
              {
               fe[0].Item3__c = itemname;
               fe[0].No3__c = noOfItems;
              }
                            
          }
       
       
       else if(fe[0].Item1__c == itemname)
         {
          fe[0].No1__c = fe[0].No1__c + noOfItems;
         }

       else if(fe[0].Item2__c == itemname)
         {
          fe[0].No2__c = fe[0].No2__c + noOfItems;
         }   
         
       else if(fe[0].Item3__c == itemname)
         {
          fe[0].No3__c = fe[0].No3__c + noOfItems;
         }               
      
          update fe[0];
     }     
      
  }
  
    
}

 When the lookup field is null, I am not able to change the Remaining_Stock__field.  Can someone please suggest a solution. I tried  !isEmpty function but still no progress

  • October 09, 2013
  • Like
  • 0

 

Hi Everyone,

                       I have the following code.

 

 

 

trigger InsertInfo on Inventory__c (before Update)
 {
    
    for(Inventory__c inv : trigger.new)
      {
         Inventory__c oldValue = Trigger.oldMap.get(inv.ID);
         { 
            
           if( inv.Remaining_Stock__c < oldValue.Remaining_Stock__c)
            { 
              
              Date date1 = Date.Today();
              String abc = String.valueOf(date1);
              Decimal numofgifts = oldValue.Remaining_Stock__c - inv.Remaining_Stock__c ;
              Integer integerValue = numofgifts.intvalue();
              String fe = inv.Field_Executive__r.Name;  // THIS IS WHERE MY PROBLEM IS
              String pqr = String.valueOf(integerValue);
                  inv.Issued_Dates__c   = inv.Issued_Dates__c + '\n' + abc +'\t\t'+ fe +'\t\t'+ pqr;
                  
            }
                 
         }
      }
  }
  

 Issued_Dates is a textbox. But instead of fe Name it displays null. Any idea where I am wrong ?

 

Thanks in advance

 

                              

 

          

  • October 08, 2013
  • Like
  • 0

Hi Everyone,

                      I used the function valueOf as following

Date date1 = Date.Today();
String abc = valueOf(date1);

 But I get the following error

 

Error: Compile Error: Method does not exist or incorrect signature: valueOf(Date) at line 10 column 28.

 

                          Can someone point me the error. I checked the syntax in the salesforce system calls list and it is the same as the one I used.

  • October 07, 2013
  • Like
  • 0

Hi Eveyone,

                     I have a trigger in which I update certain fields only if the values of some other fields are changed while updating a record.

 

                

trigger TStock_RStock on Inventory__c (after update) 
  {
     for(Inventory__c inv : trigger.new)
      {
         Inventory__c oldValue = Trigger.oldMap.get(inv.ID);
         {
           if( inv.Number_1__c != oldValue.Number_1__c)
            {
              inv.Test_Stock__c = inv.Test_Stock__c + inv.Number_1__c;
              inv.Remaining_Stock__c = inv.Remaining_Stock__c + inv.Number_1__c;
            }
            
           if( inv.Number_2__c != oldValue.Number_2__c)
            {
              inv.Test_Stock__c = inv.Test_Stock__c + inv.Number_2__c;
              inv.Remaining_Stock__c = inv.Remaining_Stock__c + inv.Number_2__c;
            }
            
           if( inv.Number_3__c != oldValue.Number_3__c)
            {
              inv.Test_Stock__c = inv.Test_Stock__c + inv.Number_3__c;
              inv.Remaining_Stock__c = inv.Remaining_Stock__c + inv.Number_3__c;
            }
             
          }
       }
   }

        But I get the following error

 

 

Error:Apex trigger TStock_RStock caused an unexpected exception, contact your administrator: TStock_RStock: execution of AfterUpdate caused by: System.FinalException: Record is read-only: Trigger.TStock_RStock: line 9, column 1

          None of the fields used in this trigger are read only, I made sure of that. Can someone please help me with this.

  • October 06, 2013
  • Like
  • 0

Hi Everyone,

 

                       I have 2 objects 'Gift__c' and 'Field_Executive__c'.    There is a lookup relation from the former to the latter. Whenever there is a name of a field executive in a newly created Gift record, an updation should occur in the record of that particular Field Executive.

                       There is a common decimal field called No_of_Gifts__c in both objects. This value should be extracted from the current Gift and it should be subtracted from the 'No_of_Gifts__c' field in the corresponding Field Executive. My code is not working. It is compiling but no updation occurs. Can someone point me the error ?

trigger Issue on Gift__c (after insert)
{

Decimal gifts=trigger.new[0].No_of_Gifts__c;
string fieldexecutive_name=trigger.new[0].Fieldexecutive__c;


List<Fieldexecutive__c> fieldexecutive=[Select Id from Fieldexecutive__c where Name=:fieldexecutive_name];

for(Fieldexecutive__c   fe:fieldexecutive)
{
    Decimal giftsfe=fe.Number_of_Gifts__c;
        if(giftsfe>=gifts)
        {
        fe.Number_of_Gifts__c=giftsfe-gifts;
        }
}
   
         update fieldexecutive;
                        
                 

}

 

  • September 25, 2013
  • Like
  • 0

Hi Everyone,

                              I am new to apex so this should be a simple question. I have a custom object with string fields. No duplicate should occur in any of these fields(before insert and before update).

                              I just want to add the duplictes to a list and in the end allow insert only if the list is NULL.

  • September 24, 2013
  • Like
  • 0

Hi everyone,
                       I have a detail page onclick javascript cutom button which need to be clicked everytime right after I save a record. Is it possible to automate this function? I heard about a click() function but it is only usable if I can override the save function. Is there some fuction I can add to the script of the custom button to achieve this?

  • September 02, 2013
  • Like
  • 0

Hi Everyone,
                      I am creating a custom list button for an object. The record Id is entered in the prompt window after the button is pressed. Is it possible to display the result in the default salesforce list itself using javascript? If not how can I display the results since visualforce is not enabled in Force.com ?

  • August 29, 2013
  • Like
  • 0

Hi everyone,

                      I have an object 'Inventory' with a field 'Issue to' and a button. A number input via prompt from this button should update a field named 'Number Of Gifts' which is in an another object named 'Field Executive'. But I am not able to pass a string in the soql statement. Is there anyway to achieve this? Here is my code.

 

 

{!requireScript("/soap/ajax/26.0/connection.js")}
var url = parent.location.href;

var inp=prompt("Enter the number of gifts to issue");       

var abc=sforce.connection.query("SELECT Issue_To__c FROM Inventory__c WHERE Id='{!Inventory__c.Id}'");       

var record1 = abc.getArray("records");

var pqr = sforce.connection.query("SELECT Id FROM Field_Executive__c WHERE Id=\''' + record1[0] + '\'");

var record2 = pqr.getArray("records");

var fe = new sforce.SObject("Field_Executive__c");

fe.Id = "abc";

fe.Number_of_Gifts__c = parseFloat(record2[0].Number_of_Gifts__c) +
parseFloat(inp);

result = sforce.connection.update([fe]);
parent.location.href = url;

 

 

 

The error says     "unexpected token: '+'', detail:{MalformedQueryFault:{exceptionCode:'MALFORMED_QUERY', exceptionMessage: ' Field_Executive__c WHERE Id='' + record1[0] + ''"

  • August 28, 2013
  • Like
  • 0

Hi everybody,

                     I am new to force.com. So I dont know much about it. Here is what I want to achieve.

 

 I have an object 'Inventory' with a custom read-only field 'Stock' and a custom button 'Add'. When 'Add' is pressed a number is input from the keyboard via prompt. Then 'Stock' should be updated to 'Stock + the input number'.

 

                 Here is my code

 

{!requireScript("/soap/ajax/26.0/connection.js")}

var url = parent.location.href;

var input=prompt("Enter the number");

var customObj = sforce.connection.query("SELECT Id FROM Inventory__c WHERE
Id='{!Inventory__c.Id}'");

customobj.Stock__c=customobj.Stock__c+input;
update customobj;

parent.location.href = url;

 

 

But it is not working. Can someone help me with this?

  • August 27, 2013
  • Like
  • 0

Hi everyone,

                      I have to insert birthday events for a custom object called Mason__c. My code is not working. Can someone point out the mistake ? Thanks in advance

trigger BirthDayEvent on Mason__c (before update) 
{
	
    List<Event> eventList = new List<Event>();

	
	for(Mason__c mason :trigger.new)
	 {
	 	if(mason.Date_Of_Birth1__c != null)
	 	{     
	 		  decimal monthint =  mason.Date_Of_Birth1__c.month();
	 		  string monthstr;
	 		  if(monthint == 1)
	 		  monthstr = 'January';
	 		  else if(monthint == 2)
	 		  monthstr = 'February';
	 		  else if(monthint == 3)
	 		  monthstr = 'March';
	 		  else if(monthint == 4)
	 		  monthstr = 'April';
	 		  else if(monthint == 5)
	 		  monthstr = 'May';
	 		  else if(monthint == 6)
	 		  monthstr = 'June';
	 		  else if(monthint == 7)
	 		  monthstr = 'July';
	 		  else if(monthint == 8)
	 		  monthstr = 'August';
	 		  else if(monthint == 9)
	 		  monthstr = 'September';
	 		  else if(monthint == 10)
	 		  monthstr = 'October';
	 		  else if(monthint == 11)
	 		  monthstr = 'November';
	 		  else if(monthint == 12)
	 		  monthstr = 'December';
	 		  
	 		  
	 		  Event event = new Event();
	 		  date dt;
              dt=date.parse('01/1/2025');
              event.Subject ='Birthday ' + mason.Child_Name_1__c;
              event.startdatetime=mason.Date_Of_Birth1__c;
              event.enddatetime=mason.Date_Of_Birth1__c;
              event.OwnerId = UserInfo.getUserId();
              event.WhatId = mason.Id;
              event.ISRECURRENCE=true;
              event.RECURRENCETYPE='RecursYearly';
           	  event.RECURRENCESTARTDATETIME= mason.Date_Of_Birth1__c;
			  event.RECURRENCEENDDATEONLY=dt;
			  event.RecurrenceMonthOfYear = monthstr;
			  event.RecurrenceDayOfMonth = mason.Date_Of_Birth1__c.day();
              event.IsReminderSet = true;
              event.ReminderDateTime = DateTime.now().addDays(-2);
              eventList.add(event);
              
          }


        }


           if(eventList.size()>0)
           {
           insert eventList;
           }
           

}

 

  • November 28, 2013
  • Like
  • 0

Hi Everyone,

                      How can I add an event for a current custom object (not just a calender event) ?

trigger SiteEvent on Site__c (after insert, after update) 
  {
    List<Event> eventList = new List<Event>();
    
      for(Site__c site : Trigger.new)
        { 
          if(site.Date_Of_Next_Level_Of_Construction__c != null)
          {
              Event event = new Event();
              event.Subject = site.Name;
              event.StartDateTime = site.Date_Of_Next_Level_Of_Construction__c;
              event.EndDateTime = site.Date_Of_Next_Level_Of_Construction__c;
              event.OwnerId = UserInfo.getUserId();
              event.IsReminderSet = true;
              event.ReminderDateTime = site.Date_Of_Next_Level_Of_Construction__c;
              
              eventList.add(event);
              
          }
        }
           if(eventList.size()>0)
           {
           insert eventList;
           }
    }

 What I want is to insert this event in the current site record itself(trigger.new)

 

Thanks in advance

  • November 23, 2013
  • Like
  • 0

Hi everyone,

                     I have a code to update a certain object called Field_Executive based on another object called inventory. It is working fine when the lookup field to FE is filled. Here is the code

trigger FEupdate on Inventory__c (before update) 
 {
   for(Inventory__c inv : trigger.new)
    {    
         Inventory__c oldValue = Trigger.oldMap.get(inv.ID);
         Decimal noOfItems = oldValue.Remaining_Stock__c - inv.Remaining_Stock__c;
         
       Id feId = inv.Field_Executive__c;
       List<Field_Executive__c> fe = [Select Id, Item1__c, Item2__c, Item3__c, No1__c, No2__c, No3__c
                                      From Field_Executive__c where Id =:feId ];  
     
     if( noOfItems != 0 && !fe.isEmpty() )
      {
       String itemname = inv.Name;
       
       if(fe[0].Item1__c != itemname && fe[0].Item2__c != itemname && fe[0].Item3__c != itemname )
          {
             if(fe[0].Item1__c == null)
              {
               fe[0].Item1__c = itemname;
               fe[0].No1__c = noOfItems;
              }

             else if(fe[0].Item2__c == null)
              {
               fe[0].Item2__c = itemname;
               fe[0].No2__c = noOfItems;
              }

             else if(fe[0].Item3__c == null)
              {
               fe[0].Item3__c = itemname;
               fe[0].No3__c = noOfItems;
              }
                            
          }
       
       
       else if(fe[0].Item1__c == itemname)
         {
          fe[0].No1__c = fe[0].No1__c + noOfItems;
         }

       else if(fe[0].Item2__c == itemname)
         {
          fe[0].No2__c = fe[0].No2__c + noOfItems;
         }   
         
       else if(fe[0].Item3__c == itemname)
         {
          fe[0].No3__c = fe[0].No3__c + noOfItems;
         }               
      
          update fe[0];
     }     
      
  }
  
    
}

 When the lookup field is null, I am not able to change the Remaining_Stock__field.  Can someone please suggest a solution. I tried  !isEmpty function but still no progress

  • October 09, 2013
  • Like
  • 0

 

Hi Everyone,

                       I have the following code.

 

 

 

trigger InsertInfo on Inventory__c (before Update)
 {
    
    for(Inventory__c inv : trigger.new)
      {
         Inventory__c oldValue = Trigger.oldMap.get(inv.ID);
         { 
            
           if( inv.Remaining_Stock__c < oldValue.Remaining_Stock__c)
            { 
              
              Date date1 = Date.Today();
              String abc = String.valueOf(date1);
              Decimal numofgifts = oldValue.Remaining_Stock__c - inv.Remaining_Stock__c ;
              Integer integerValue = numofgifts.intvalue();
              String fe = inv.Field_Executive__r.Name;  // THIS IS WHERE MY PROBLEM IS
              String pqr = String.valueOf(integerValue);
                  inv.Issued_Dates__c   = inv.Issued_Dates__c + '\n' + abc +'\t\t'+ fe +'\t\t'+ pqr;
                  
            }
                 
         }
      }
  }
  

 Issued_Dates is a textbox. But instead of fe Name it displays null. Any idea where I am wrong ?

 

Thanks in advance

 

                              

 

          

  • October 08, 2013
  • Like
  • 0

Hi Everyone,

                      I used the function valueOf as following

Date date1 = Date.Today();
String abc = valueOf(date1);

 But I get the following error

 

Error: Compile Error: Method does not exist or incorrect signature: valueOf(Date) at line 10 column 28.

 

                          Can someone point me the error. I checked the syntax in the salesforce system calls list and it is the same as the one I used.

  • October 07, 2013
  • Like
  • 0

Hi Eveyone,

                     I have a trigger in which I update certain fields only if the values of some other fields are changed while updating a record.

 

                

trigger TStock_RStock on Inventory__c (after update) 
  {
     for(Inventory__c inv : trigger.new)
      {
         Inventory__c oldValue = Trigger.oldMap.get(inv.ID);
         {
           if( inv.Number_1__c != oldValue.Number_1__c)
            {
              inv.Test_Stock__c = inv.Test_Stock__c + inv.Number_1__c;
              inv.Remaining_Stock__c = inv.Remaining_Stock__c + inv.Number_1__c;
            }
            
           if( inv.Number_2__c != oldValue.Number_2__c)
            {
              inv.Test_Stock__c = inv.Test_Stock__c + inv.Number_2__c;
              inv.Remaining_Stock__c = inv.Remaining_Stock__c + inv.Number_2__c;
            }
            
           if( inv.Number_3__c != oldValue.Number_3__c)
            {
              inv.Test_Stock__c = inv.Test_Stock__c + inv.Number_3__c;
              inv.Remaining_Stock__c = inv.Remaining_Stock__c + inv.Number_3__c;
            }
             
          }
       }
   }

        But I get the following error

 

 

Error:Apex trigger TStock_RStock caused an unexpected exception, contact your administrator: TStock_RStock: execution of AfterUpdate caused by: System.FinalException: Record is read-only: Trigger.TStock_RStock: line 9, column 1

          None of the fields used in this trigger are read only, I made sure of that. Can someone please help me with this.

  • October 06, 2013
  • Like
  • 0

Hi Everyone,

 

                       I have 2 objects 'Gift__c' and 'Field_Executive__c'.    There is a lookup relation from the former to the latter. Whenever there is a name of a field executive in a newly created Gift record, an updation should occur in the record of that particular Field Executive.

                       There is a common decimal field called No_of_Gifts__c in both objects. This value should be extracted from the current Gift and it should be subtracted from the 'No_of_Gifts__c' field in the corresponding Field Executive. My code is not working. It is compiling but no updation occurs. Can someone point me the error ?

trigger Issue on Gift__c (after insert)
{

Decimal gifts=trigger.new[0].No_of_Gifts__c;
string fieldexecutive_name=trigger.new[0].Fieldexecutive__c;


List<Fieldexecutive__c> fieldexecutive=[Select Id from Fieldexecutive__c where Name=:fieldexecutive_name];

for(Fieldexecutive__c   fe:fieldexecutive)
{
    Decimal giftsfe=fe.Number_of_Gifts__c;
        if(giftsfe>=gifts)
        {
        fe.Number_of_Gifts__c=giftsfe-gifts;
        }
}
   
         update fieldexecutive;
                        
                 

}

 

  • September 25, 2013
  • Like
  • 0

Hi Everyone,

                              I am new to apex so this should be a simple question. I have a custom object with string fields. No duplicate should occur in any of these fields(before insert and before update).

                              I just want to add the duplictes to a list and in the end allow insert only if the list is NULL.

  • September 24, 2013
  • Like
  • 0