function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Deloitte IT Admin 2Deloitte IT Admin 2 

Problem with Save method

Hi All,

i've got this Save method that gets called when users press a button. If users press it more than one time while the page is not completely loaded, this causes problems. 
Any idea on how to solve this issue? Here's the save method:
 
public PageReference save() {
    
        update ppl ;
        Boolean fyok = true;
        Set<Decimal> fypresent = new Set<Decimal>();
        for (Pipeline_Item__c pl: ppl.Pipeline_Items__r)
        {
            if (pl.Fiscal_Year__c!= null && pl.Fiscal_Year__c!= 0)
            {
                if (fypresent.contains(pl.Fiscal_Year__c)){
                  fyok = false;
                }
                fypresent.add(pl.Fiscal_Year__c);
          } 
        }
        if (fyok){
            for (Pipeline_Item__c pl: ppl.Pipeline_Items__r)
            {
                update pl;
            }
      }
      reload();
      update ppl ;

      fyok = true;
       fypresent = new Set<Decimal>();
        for (Pipeline_Item__c pl: ppl.Pipeline_Items__r)
        {
            if (pl.Fiscal_Year__c!= null && pl.Fiscal_Year__c!= 0)
            {
                if (fypresent.contains(pl.Fiscal_Year__c)){
                  fyok = false;
                }
                fypresent.add(pl.Fiscal_Year__c);
          }
        }
        if (fyok){
            for (Pipeline_Item__c pl: ppl.Pipeline_Items__r)
            {
                update pl;
            }
      }

       updateActualsMor();  
       return null;
     
        reload();
        return null;
    }