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
Gab SilvermotionGab Silvermotion 

newbie apex code question

Hello, i need to modify the code of an existing trigger in our salesforce. the original trigger was coded by a firm we a no longer dealing with.

basically, the trigger automatically changes the stage of the opportunity depending on actions the sales rep are doing (calling, sending emails, receiving prospects in the sales office)

so here's the deal.

existing code :

if (e.Type != null && e.Type == 'Walk-In')
      walkin++;

id like to modify it so the walkin+++ occurs not only when there is a event named ''walk-in", but also for all those containing "Meeting".

the event type "walk-in" is for when a prospect visits a sales office unnanounced.  we added 1st meeting, 2nd meeting, 3rd meeting, 4th+ meeting as event types to log when the prospects visits after they have talked to a sales rep.

so i guess something like

If (e.Type !=null && (e.Type == ‘Walk-In’ || e.Type.contains(‘Meeting’))
Walkin++

??

thanks for the help, i'm new at apex development and it's a bit overwhelmong at first.

since i'm modifying an existing trigger, can i just change it in the dev console and save?

thank you!
Best Answer chosen by Gab Silvermotion
Phillip SouthernPhillip Southern
You got it...and if == works for walk-in you can do the same for meeting....so:   e.Type == 'Meeting'

You can edit in the dev console but only in sandbox.  For apex code (triggers and classes) you can't edit in production.  So you'll need to edit it in a sandbox and then you can do a change set to push it to production.

All Answers

Phillip SouthernPhillip Southern
You got it...and if == works for walk-in you can do the same for meeting....so:   e.Type == 'Meeting'

You can edit in the dev console but only in sandbox.  For apex code (triggers and classes) you can't edit in production.  So you'll need to edit it in a sandbox and then you can do a change set to push it to production.
This was selected as the best answer
Ramu_SFDCRamu_SFDC
I assume your question is about editing the trigger directly on Production org. Unfortunately, editing triggers or apex on production org is not allowed if it is not a Dev org or sandbox org or trial org. The change you are planning to do is correct however you first need to make these changes on your sandbox org ,check the test coverage and then deploy it to your production org.

Below is a salesforce.com article that explains more on the limitations of editing apex/triggers on production org.

http://help.salesforce.com/apex/HTViewSolution?id=000005267&language=en_US

Hope this answers your question !!
Gab SilvermotionGab Silvermotion
allright! i created a sandbox, opened up the dev console, modified the code, ran the test, tested if the changes were working in the sandbox itself (and they are working, yay!),  

i'm searching the documentation on how to push it in production now. thank you very much!