• Frances Allen
  • NEWBIE
  • 30 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 20
    Questions
  • 17
    Replies
I have a report with a unique custom field (picklist) that is pulling a blank value when it should pull a 'yes'. I've tried doing data loader, but this thing keeps showing the bad value. It is not a multi-select picklist! 
I'm having an issue with an approval process that has atypical routing needs. Can someone tell me if this is possible? 

Submitter submites to first approver. 
When first approver rejects it is sent back to submitter 
When the submitter resubmits the opportunity then goes to approver 2 (not approver 1) 
Then the opportunity is sent to approver 1 upon approval. 

No matter what I do, my opportunities keep submitting to the first approver. I've tried designing a second approval process for approver 2 using a hidden field to delineate it from the approval process that is connected to approver 1. 

Should I use Process Builder or should I just stick to the approval process. I cannot deploy any classes, so code solutions won't work.
I'd like to preface this post saying that I do not have access to create triggers in my Org currently. I'm automating this process entirely through Process Builder. 

The problem: 
I've created a process that checks a box on contact records after a record for another object is created. I'll refer to this object as 'availability'.  After a record for availbility is created, the checkbox located on a contact record is checked. It's that simple. However, I want to validate when there are no more availability records ( no availability records exist ) and uncheck that box when someone has erased their last availability record. 

The question:
What formula could I use to check if the boolean on contacts is checked, validate that there are no more availability records, and then uncheck the box? 

Any solutions or ideas would be appreciated.
Besides using the documentation located here: 
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_visualforceaccessmetrics.htm

What are other ways to query how many visualforce pages exist in your org? I feel like there is an easier way to do this, like looking under 
pages in setup? What special advantage does querying give you? 



 
I want to preface that I am using the newest version of files for Salesforce Lightning, not classic Notes and Attachments.

We want to ensure that at least one file is uploaded to an opportunity in notes and attachments ( we have enabled files so the upload is of Salesforce files ). 

I cannot see how validation is possible from the opportunity itself. Is anyone doing this without using Process Builder or a Trigger? 

Thanks in Advance.
Hello All, 

I believe that this formula is incorrect in that we cannot use an if statement this way. If there are any pros on the board that quickly double-check my knowledge.
The purpose of this field is to determine current school year according to fiscal year which is after July. 

IF (MONTH(TODAY())>=7, YEAR(TODAY())+1,
IF (MONTH(TODAY())<7, YEAR(TODAY()),0))
IF (MONTH(TODAY())>=7, YEAR(TODAY())+1,
IF (MONTH(TODAY())<7, YEAR(TODAY()),0))

If today’s month is greater or equal to July add one more year to the year otherwise if false  
And today’s month is is less July, todays year, otherwise 0
 
Wouldn’t it be just YEAR(TODAY()) with no comma and zero following?



 
I want to edit our stage forecasing so that the committed date will not show up as the closed date. I have changed the category from closed to open, but I the system seems to get buggy and then changes it back after that. Has anyone tried to customize their stages and experienced this error before? 

 
For instance, if I log into a Salesforce community and I'm a 'cat' record type, would I then have the option to create a 'dog' record type if I'm not assigned this record type? How can you restrict their access to creating a 'dog' record type? Basically, I need to confirm that a specific user with a certain record type cannot create a record that is not their record type.
I know that this error is referring my user update in line 14, but appears to be a mistake that is actually masking another mistake as I've already identified the user id with contact id in my code.

My full error upon deployment is :  
System.DmlException: Update failed. First exception on row 0; first error: MISSING_ARGUMENT, Id not specified in an update call: []
Stack Trace: Class.IncompleteWorkshopLogsTest.testOnlyIncompleteWorkshopsReturned: line 14, column 1

Line 14  is 
update u;
The controller is here: 
@isTest
public class IncompleteWorkshopLogsTest {

   @isTest
   private static void testOnlyIncompleteWorkshopsReturned() {
       
       //create contact
       Contact c = new Contact(FirstName='Test', LastName = 'Test');
       insert c;
       
       User u = new User();
       u.ContactId = c.Id;
       
       update u; 
       
       //tie teaching to a volunteer and contact id 
       Workshop_Signup__c incompleteLog = new Workshop_Signup__c(
           Volunteer__c = c.Id    
       );
       
       insert incompleteLog;

       Workshop_Signup__c completeLog = new Workshop_Signup__c(
           Volunteer__c = c.Id
       );
       
       insert completeLog;

       //create and insert a workshop log that would indicate one finished vs. unfinished
       Workshop_log__c unfinished = new Workshop_log__c(RCM_A9__c = '');
       Workshop_log__c finished = new Workshop_log__c(RCM_A9__c = 'Complete');
       
       // tie workshop log to teaching record 
       incompleteLog.Id = unfinished.Id;
       completeLog.Id = finished.Id;
       insert  unfinished;
       insert  finished;
       
       insert new List<Workshop_Signup__c> { completeLog, incompleteLog };
        

       Test.startTest();

       IncompleteWorkshopLogs controller = new IncompleteWorkshopLogs();

       List<Workshop_Signup__c> results = controller.getTeaching();
       
       update results;

       Test.stopTest();

       System.assertEquals(1, results.size());
       System.assertEquals('Complete', results[0].Workshop_Log_Status__c);
      
   }
}

Tests have been a major roadblock in getting things deployed here, so any assistance would be appreciated.

Thanks, 

Frances 

  
I want to show payment data on a visual force page. I cannot get this to work. I am thinking that I have correctly queried through a nested relationship statement and all is well, but this is not happening.  The visualforce page is here: 
   
<apex:page controller="TestRollUpData">
    <apex:form >
        <apex:pageBlock title="Tests" id="more_tests">
			<apex:pageBlockTable value="{! Opportunity }" var="o">
                <apex:column value="{! o.Name}"/>
                <apex:column value="{! o.Designated_Fiscal_Year__c}"/>
                <apex:column value="{! o.Amount}"/>
            </apex:pageBlockTable>
            <apex:pageBlockTable value="{! o.npe01__OppPayment__r }" var="x">
                <apex:column value="{! x.npe01__Payment_Date__c}"/>
            </apex:pageBlockTable>
            <apex:repeat value="{! Opportunity }" var="x">
              <script>
                  document.getElementById('totalRevenue').value =
                 parseFloat(document.getElementById('totalRevenue').value) + {! Opportunity.Amount};
              </script>
            </apex:repeat>
        </apex:pageBlock>
    </apex:form>
</apex:page>

and the controller is here:
 
public class TestRollUpData {
    

   
    public List<Opportunity> getOpportunity(){ 
    
         List<Opportunity> tests = [SELECT Name, Amount, Designated_fiscal_year__c,
                                    (SELECT npe01__Payment_Date__c FROM  npe01__OppPayment__r ) FROM Opportunity 
            WHERE Designated_fiscal_year__c = '2020-2021' LIMIT 10];	
           
           return tests;
           
         }
    
    }

​Does anyone have any idea if this is because my npe01__OppPayment__r field is reference NPSP managed fields and is not standard Salesforce payment or is this just a bad query? I think theoretically this makes sense. Why will this not show on the page? The only error I'm getting is Unknown property 'TestRollUpData.o'. On my TestRollUpData page and controller.

Thanks.
 
Hello, 

Has anyone else been able to reduce these error messages through programmatic means? These errors seem to be coming from a managed package which, in my experience, have been very difficult to to intercept or interpret code wise. The npsp class is why I know this is the Non-Profit Success Pack at work. Does anyone have experience specifically with identifying the types of processes which would be causing this? I believe that it is mass data manipulation, or users uploading many records into the system.

Thank You,

Frances Allen 
Our users in Salesforce have the email format on creation: 
jcarroll=mycompany.com@example.com 

Somehow I've managed to change my email address to a proper form of 
rsmith@mycompany.com.

When I try to change any other users' emails the format always reverts back to the same as in the first example. In other words, I cannot change it from jcarroll=mycompany.com@example.com  to jcarroll@mycompany.com.

Rather than log a case I though I'd get input from people here first.
Hello,

I'm trying to change emails within a sandbox so I can test an approvals process. The sandbox email contains an equal sign in this format tsmith=mycompany.org. Everytime I try to save as tsmith@mycompany.org it just changes back to tsmith=mycompany.org. Does anyone have a clue as to why this is and how I can change emails? 
Is there a way to prevent users from changing an opportunity, but allowing them to make edits on an opportunity? For example, I want to submit an alteration request in an approval, but I change the fields I was changed before sending it over to the approver? I don't believe this is plausible. They'd have to save their changes, and my validation prevents them from altering the record after a committed stage. 

The reason I want to do this is to cut down on the emails that would need to be sent in verifying the changes that need to be made on the opportunity. I would just put in the error message 'contact the finance manager for changes to committed records.'

Thanks.
Hello, 

I am wondering is anyone else has had this problem. When we are refreshing the dashboards, the dashboard just turns to code. It isn't anymore complicated than that. Literally, it is just html tags and styling. Does anyone know why this might be? 

Thanks.
If there is a post out there that covers this specifically, feel free to point me in that direction. I've researched the tar out of this one.

I need to update a picklist with a trigger using a value that is already a global value, not inserting a new value. The picklist gives me dates in this format:

2018 - 2019
2016 - 2017
etc.

I want the trigger to update a picklist value that is '2016 - 2017' to '2018 - 2019' after the record is saved. Originally, I was thinking that Apex might treat these values as an array and I could iterate from [0] to [1] etc. I don't see this capability baked into any code out there. I'm aware of the getPickListValue(), but this method seems to be used for value insertion or detection, not update.

Is this type of updating possible in Apex? If so, how? If not, are there Salesforce tools I can use to essentially tell the system ' on selection of this boolean field, after a save, update the picklist value to the next in the sequence' - as we're never going to skip years on this update. This picklist exists to place opportunities into a consecutive fiscal year.

Thanks All.
I want to clone a record through Apex using a trigger to customize staging and update date fields.
I've run into two problems:

1. My original record isn't saved. I want the original record to save and a copy to be made from it. I'm looking for an automatic cloning action essentially.

The copy is known by the addage "planning" onto the name of the Opportunity.

2. The trigger is acting on all updates, meaning I can't change and save a field without activating the trigger. Do
I just need to change the parameters? Is there a way to check and limit with Trigger.Old?

Trigger that conditionally stages.
trigger FinancialPlanning on Opportunity (before update) {
 List<Opportunity> oppList = new List<Opportunity>();
    //creating list of opps in which items will live  
    for(Opportunity x : Trigger.new) {
          x.Name = x.Name + ' planning';
          
      
          if (x.StageName == '0 - Deferred'){
    			x.StageName = '1 - Research';
                x.Ask_Ready_Date__c = x.Ask_Ready_Date__c + 365;
                x.npsp__Ask_Date__c = x.npsp__Ask_Date__c + 365;
                x.Verbal_Date__c = x.Verbal_Date__c + 365; 
                x.Committed_Date__c = x.Committed_Date__c +365; 
                x.CloseDate = x.CloseDate + 365;
              
          }else if (x.StageName == '0 - Declined'){
                x.StageName = '1 - Research';
                x.Ask_Ready_Date__c = x.Ask_Ready_Date__c + 365;
                x.npsp__Ask_Date__c = x.npsp__Ask_Date__c + 365;
                x.Verbal_Date__c = x.Verbal_Date__c + 365; 
                x.Committed_Date__c = x.Committed_Date__c +365; 
                x.CloseDate = x.CloseDate + 365;
                
          }else if (x.StageName == '0 - Unresponsive') {
                x.StageName = '1 - Research';
                x.Ask_Ready_Date__c = x.Ask_Ready_Date__c + 365;
                x.npsp__Ask_Date__c = x.npsp__Ask_Date__c + 365;
                x.Verbal_Date__c = x.Verbal_Date__c + 365; 
                x.Committed_Date__c = x.Committed_Date__c +365; 
                x.CloseDate = x.CloseDate + 365;
               
          }else if (x.StageName == '1 - Research') {
				x.Ask_Ready_Date__c = x.Ask_Ready_Date__c + 365;
                x.npsp__Ask_Date__c = x.npsp__Ask_Date__c + 365;
                x.Verbal_Date__c = x.Verbal_Date__c + 365; 
                x.Committed_Date__c = x.Committed_Date__c +365; 
                x.CloseDate = x.CloseDate + 365;
               
          }else if (x.StageName == '2 - Intro'){
                x.Ask_Ready_Date__c = x.Ask_Ready_Date__c + 365;
                x.npsp__Ask_Date__c = x.npsp__Ask_Date__c + 365;
                x.Verbal_Date__c = x.Verbal_Date__c + 365; 
                x.Committed_Date__c = x.Committed_Date__c +365; 
                x.CloseDate = x.CloseDate + 365;
              
          }else if (x.StageName == '3 - Educate'){
                x.Ask_Ready_Date__c = x.Ask_Ready_Date__c + 365;
                x.npsp__Ask_Date__c = x.npsp__Ask_Date__c + 365;
                x.Verbal_Date__c = x.Verbal_Date__c + 365; 
                x.Committed_Date__c = x.Committed_Date__c +365; 
                x.CloseDate = x.CloseDate + 365;
              
          }else if (x.StageName == '4 - Ask Ready'){
                x.npsp__Ask_Date__c = x.npsp__Ask_Date__c + 365;
                x.Verbal_Date__c = x.Verbal_Date__c + 365; 
                x.Committed_Date__c = x.Committed_Date__c +365; 
                x.CloseDate = x.CloseDate + 365;
              
          }else if (x.StageName == '5 - Request'){
                x.Verbal_Date__c = x.Verbal_Date__c + 365; 
                x.Committed_Date__c = x.Committed_Date__c +365; 
                x.CloseDate = x.CloseDate + 365;
              
          }else if (x.StageName == '6 - Verbal'){
                x.Committed_Date__c = x.Committed_Date__c +365; 
                x.CloseDate = x.CloseDate + 365;
              
          }else if (x.StageName == '7 - Committed'){
                x.Committed_Date__c = x.Committed_Date__c +365; 
                x.CloseDate = x.CloseDate + 365;
              
          }else{
                x.Committed_Date__c = x.Committed_Date__c +365; 
                x.CloseDate = x.CloseDate + 365;
          }
          //get this picklist's value and update field with method. 
          x.Designated_Fiscal_Year__c = x.Designated_Fiscal_Year__c ; 
		  
        if (oppList.size() > 0) insert oppList;
            oppList.add(x);
      }
     
}
Here is what I've got in my controller class:
public class FinancialCloningController {
    //added an instance varaible for the standard controller
    private ApexPages.StandardController controller {get; set;}
    
    //instance for the variables being passed by id on the url
	private Opportunity opp {get;set;}
    
    //set the id of the record that is created
    public ID newRecordId {get;set;}
    
    public FinancialCloningController(ApexPages.StandardController controller) {
        this.opp = (Opportunity)controller.getRecord();
        this.controller = controller;
        opp = (Opportunity)controller.getRecord(); 
         
    }
    
    public PageReference cloneOpportunity() {

         // setup the save point for rollback
         Savepoint sp = Database.setSavepoint();
         Opportunity newOpp;

         try{

             //Copy the Opportunity - only include the records you want to clone 
             opp = [SELECT Id, Name, StageName FROM Opportunity WHERE ID = :opp.id];
             insert newOpp;
             newOpp.clone(false, false, false, false);

             //set the id of the new po created for testing
             newRecordId = newOpp.id;
             

         } catch (Exception e){
             // roll everything back in case of error
            Database.rollback(sp);
            ApexPages.addMessages(e);
            return null;
         }

          return new PageReference('/'+newOpp.id+'/e?retURL=%2F'+newOpp.id);
        
    }

}
I'm not sure that I can isolate a triggers actions to a button. Obviously, I'm very new to Salesforce and don't know if there is a way to do this without triggers. I feel the trigger is too powerful in this case. Why is the original record saving as a new record (conditional logic is fine and works), and can this trigger be isolated to a button action?

Thanks.





 
This is more of a general question based off of the ideas presented here:
https://developer.salesforce.com/forums/?id=906F00000008jgSIAQ

I want to clone opportunities through a 'duplicate' button that not only clones the record, but also then performs actions on the record through a trigger. My question is whether the trigger is necessary on save or not. Through process builder, could I possibly update certain fields upon execution of a button action? For example, upon duplication these fields will update from x to y. I'm new to the Salesforce development community, but feel I should avoid URL hacking at all costs as it will become deprecated upon the advent of Lightning. Is there an updated version of this customized cloning approach? Any links / solution appreciated.

Thanks
I want to filter records in Salesforce depending upon what custom picklist option is selected for our custom field Application_status__c.

AFTER this filter takes place, I want to iterate through a Contacts list that meets a specific criteria and print them out to a list. My issue is:

1. SOQL does not allow querying of custom picklist values. 
2.  Application__c on which Application_status__c (my picklist) is located, cannot be accessed from standard Contact object. So my code would check out this data and use Contact SOQL. For a newbie this is kind of arcane knowledge.

I know I need the .getDescribe() method.

I need to only select the individuals who meet the Contacts list criteria after checking application picklist status, but I cannot figure out how to get SOQL and my idea to work together. Will this need to be re-written or can I plug in a method within the SOQL?
User-added image

This is ideally the pseudo code that I would want to filter through the above list:

User-added image

Thank You.


 
The business logic is that all financial information that is classified under Stage 7 is handed over to the finance department on the 10th of the following month. For example, all Stage 7 financial fields of September should be closed on the October 10th. After October 10th, I don't want anyone but finance to have access to a restricted field. Ideally, I like the logic behind this solution:

http://www.salesforcetutorial.com/field-level-security-salesforce/

My psuedo code for this would be
If the month and day of the current month are at the 10th, then all expected payments amount fields for the last month should be locked.
Is there a date function that calculates last month only or am I overthinking and should put something like MONTH() - 1?




 
Hello, 

I am wondering is anyone else has had this problem. When we are refreshing the dashboards, the dashboard just turns to code. It isn't anymore complicated than that. Literally, it is just html tags and styling. Does anyone know why this might be? 

Thanks.
Besides using the documentation located here: 
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_visualforceaccessmetrics.htm

What are other ways to query how many visualforce pages exist in your org? I feel like there is an easier way to do this, like looking under 
pages in setup? What special advantage does querying give you? 



 
I want to preface that I am using the newest version of files for Salesforce Lightning, not classic Notes and Attachments.

We want to ensure that at least one file is uploaded to an opportunity in notes and attachments ( we have enabled files so the upload is of Salesforce files ). 

I cannot see how validation is possible from the opportunity itself. Is anyone doing this without using Process Builder or a Trigger? 

Thanks in Advance.
Hello All, 

I believe that this formula is incorrect in that we cannot use an if statement this way. If there are any pros on the board that quickly double-check my knowledge.
The purpose of this field is to determine current school year according to fiscal year which is after July. 

IF (MONTH(TODAY())>=7, YEAR(TODAY())+1,
IF (MONTH(TODAY())<7, YEAR(TODAY()),0))
IF (MONTH(TODAY())>=7, YEAR(TODAY())+1,
IF (MONTH(TODAY())<7, YEAR(TODAY()),0))

If today’s month is greater or equal to July add one more year to the year otherwise if false  
And today’s month is is less July, todays year, otherwise 0
 
Wouldn’t it be just YEAR(TODAY()) with no comma and zero following?



 
I want to show payment data on a visual force page. I cannot get this to work. I am thinking that I have correctly queried through a nested relationship statement and all is well, but this is not happening.  The visualforce page is here: 
   
<apex:page controller="TestRollUpData">
    <apex:form >
        <apex:pageBlock title="Tests" id="more_tests">
			<apex:pageBlockTable value="{! Opportunity }" var="o">
                <apex:column value="{! o.Name}"/>
                <apex:column value="{! o.Designated_Fiscal_Year__c}"/>
                <apex:column value="{! o.Amount}"/>
            </apex:pageBlockTable>
            <apex:pageBlockTable value="{! o.npe01__OppPayment__r }" var="x">
                <apex:column value="{! x.npe01__Payment_Date__c}"/>
            </apex:pageBlockTable>
            <apex:repeat value="{! Opportunity }" var="x">
              <script>
                  document.getElementById('totalRevenue').value =
                 parseFloat(document.getElementById('totalRevenue').value) + {! Opportunity.Amount};
              </script>
            </apex:repeat>
        </apex:pageBlock>
    </apex:form>
</apex:page>

and the controller is here:
 
public class TestRollUpData {
    

   
    public List<Opportunity> getOpportunity(){ 
    
         List<Opportunity> tests = [SELECT Name, Amount, Designated_fiscal_year__c,
                                    (SELECT npe01__Payment_Date__c FROM  npe01__OppPayment__r ) FROM Opportunity 
            WHERE Designated_fiscal_year__c = '2020-2021' LIMIT 10];	
           
           return tests;
           
         }
    
    }

​Does anyone have any idea if this is because my npe01__OppPayment__r field is reference NPSP managed fields and is not standard Salesforce payment or is this just a bad query? I think theoretically this makes sense. Why will this not show on the page? The only error I'm getting is Unknown property 'TestRollUpData.o'. On my TestRollUpData page and controller.

Thanks.
 
Our users in Salesforce have the email format on creation: 
jcarroll=mycompany.com@example.com 

Somehow I've managed to change my email address to a proper form of 
rsmith@mycompany.com.

When I try to change any other users' emails the format always reverts back to the same as in the first example. In other words, I cannot change it from jcarroll=mycompany.com@example.com  to jcarroll@mycompany.com.

Rather than log a case I though I'd get input from people here first.
Hello, 

I am wondering is anyone else has had this problem. When we are refreshing the dashboards, the dashboard just turns to code. It isn't anymore complicated than that. Literally, it is just html tags and styling. Does anyone know why this might be? 

Thanks.
I want to clone a record through Apex using a trigger to customize staging and update date fields.
I've run into two problems:

1. My original record isn't saved. I want the original record to save and a copy to be made from it. I'm looking for an automatic cloning action essentially.

The copy is known by the addage "planning" onto the name of the Opportunity.

2. The trigger is acting on all updates, meaning I can't change and save a field without activating the trigger. Do
I just need to change the parameters? Is there a way to check and limit with Trigger.Old?

Trigger that conditionally stages.
trigger FinancialPlanning on Opportunity (before update) {
 List<Opportunity> oppList = new List<Opportunity>();
    //creating list of opps in which items will live  
    for(Opportunity x : Trigger.new) {
          x.Name = x.Name + ' planning';
          
      
          if (x.StageName == '0 - Deferred'){
    			x.StageName = '1 - Research';
                x.Ask_Ready_Date__c = x.Ask_Ready_Date__c + 365;
                x.npsp__Ask_Date__c = x.npsp__Ask_Date__c + 365;
                x.Verbal_Date__c = x.Verbal_Date__c + 365; 
                x.Committed_Date__c = x.Committed_Date__c +365; 
                x.CloseDate = x.CloseDate + 365;
              
          }else if (x.StageName == '0 - Declined'){
                x.StageName = '1 - Research';
                x.Ask_Ready_Date__c = x.Ask_Ready_Date__c + 365;
                x.npsp__Ask_Date__c = x.npsp__Ask_Date__c + 365;
                x.Verbal_Date__c = x.Verbal_Date__c + 365; 
                x.Committed_Date__c = x.Committed_Date__c +365; 
                x.CloseDate = x.CloseDate + 365;
                
          }else if (x.StageName == '0 - Unresponsive') {
                x.StageName = '1 - Research';
                x.Ask_Ready_Date__c = x.Ask_Ready_Date__c + 365;
                x.npsp__Ask_Date__c = x.npsp__Ask_Date__c + 365;
                x.Verbal_Date__c = x.Verbal_Date__c + 365; 
                x.Committed_Date__c = x.Committed_Date__c +365; 
                x.CloseDate = x.CloseDate + 365;
               
          }else if (x.StageName == '1 - Research') {
				x.Ask_Ready_Date__c = x.Ask_Ready_Date__c + 365;
                x.npsp__Ask_Date__c = x.npsp__Ask_Date__c + 365;
                x.Verbal_Date__c = x.Verbal_Date__c + 365; 
                x.Committed_Date__c = x.Committed_Date__c +365; 
                x.CloseDate = x.CloseDate + 365;
               
          }else if (x.StageName == '2 - Intro'){
                x.Ask_Ready_Date__c = x.Ask_Ready_Date__c + 365;
                x.npsp__Ask_Date__c = x.npsp__Ask_Date__c + 365;
                x.Verbal_Date__c = x.Verbal_Date__c + 365; 
                x.Committed_Date__c = x.Committed_Date__c +365; 
                x.CloseDate = x.CloseDate + 365;
              
          }else if (x.StageName == '3 - Educate'){
                x.Ask_Ready_Date__c = x.Ask_Ready_Date__c + 365;
                x.npsp__Ask_Date__c = x.npsp__Ask_Date__c + 365;
                x.Verbal_Date__c = x.Verbal_Date__c + 365; 
                x.Committed_Date__c = x.Committed_Date__c +365; 
                x.CloseDate = x.CloseDate + 365;
              
          }else if (x.StageName == '4 - Ask Ready'){
                x.npsp__Ask_Date__c = x.npsp__Ask_Date__c + 365;
                x.Verbal_Date__c = x.Verbal_Date__c + 365; 
                x.Committed_Date__c = x.Committed_Date__c +365; 
                x.CloseDate = x.CloseDate + 365;
              
          }else if (x.StageName == '5 - Request'){
                x.Verbal_Date__c = x.Verbal_Date__c + 365; 
                x.Committed_Date__c = x.Committed_Date__c +365; 
                x.CloseDate = x.CloseDate + 365;
              
          }else if (x.StageName == '6 - Verbal'){
                x.Committed_Date__c = x.Committed_Date__c +365; 
                x.CloseDate = x.CloseDate + 365;
              
          }else if (x.StageName == '7 - Committed'){
                x.Committed_Date__c = x.Committed_Date__c +365; 
                x.CloseDate = x.CloseDate + 365;
              
          }else{
                x.Committed_Date__c = x.Committed_Date__c +365; 
                x.CloseDate = x.CloseDate + 365;
          }
          //get this picklist's value and update field with method. 
          x.Designated_Fiscal_Year__c = x.Designated_Fiscal_Year__c ; 
		  
        if (oppList.size() > 0) insert oppList;
            oppList.add(x);
      }
     
}
Here is what I've got in my controller class:
public class FinancialCloningController {
    //added an instance varaible for the standard controller
    private ApexPages.StandardController controller {get; set;}
    
    //instance for the variables being passed by id on the url
	private Opportunity opp {get;set;}
    
    //set the id of the record that is created
    public ID newRecordId {get;set;}
    
    public FinancialCloningController(ApexPages.StandardController controller) {
        this.opp = (Opportunity)controller.getRecord();
        this.controller = controller;
        opp = (Opportunity)controller.getRecord(); 
         
    }
    
    public PageReference cloneOpportunity() {

         // setup the save point for rollback
         Savepoint sp = Database.setSavepoint();
         Opportunity newOpp;

         try{

             //Copy the Opportunity - only include the records you want to clone 
             opp = [SELECT Id, Name, StageName FROM Opportunity WHERE ID = :opp.id];
             insert newOpp;
             newOpp.clone(false, false, false, false);

             //set the id of the new po created for testing
             newRecordId = newOpp.id;
             

         } catch (Exception e){
             // roll everything back in case of error
            Database.rollback(sp);
            ApexPages.addMessages(e);
            return null;
         }

          return new PageReference('/'+newOpp.id+'/e?retURL=%2F'+newOpp.id);
        
    }

}
I'm not sure that I can isolate a triggers actions to a button. Obviously, I'm very new to Salesforce and don't know if there is a way to do this without triggers. I feel the trigger is too powerful in this case. Why is the original record saving as a new record (conditional logic is fine and works), and can this trigger be isolated to a button action?

Thanks.





 
The business logic is that all financial information that is classified under Stage 7 is handed over to the finance department on the 10th of the following month. For example, all Stage 7 financial fields of September should be closed on the October 10th. After October 10th, I don't want anyone but finance to have access to a restricted field. Ideally, I like the logic behind this solution:

http://www.salesforcetutorial.com/field-level-security-salesforce/

My psuedo code for this would be
If the month and day of the current month are at the 10th, then all expected payments amount fields for the last month should be locked.
Is there a date function that calculates last month only or am I overthinking and should put something like MONTH() - 1?