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
mukesh gupta 8mukesh gupta 8 

Trigger

Hi Experts,

Is it possible to execute this trigger in dveloper console without any test class.

example: -

trigger CountFriends on Contact(before insert) {
  for (Contact c : Trigger.new) {
    // We often use System.debug to see the values of variables
    System.debug('mukesh has a new friend!');
    System.debug('Hi ' + c.FirstName + ' ' + c.LastName + '!');
  }
  List<Contact> total = [SELECT Id FROM Contact];
  System.debug('mukesh has ' + total.size() + ' friends total.');
}

i am using same trigger in developer console but nothing happeing.

Pls help.

Thank's
 
Best Answer chosen by mukesh gupta 8
sandeep sankhlasandeep sankhla
Hi Mukesh,

You can not execute same code in develiper console...because trigger fires when some event occurs..

Now Logic whihc is inside the trigger , you can execute from developer console...

Let me knwo what exactly you are trying to do..I would advise to go for testclass if you want to test ypur trigger ..test class is very simple to create adn validate our trigger..let me know if you need anything..

P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.

Thanks,
Sandeep
Salesforce Certified Developer 

All Answers

KaranrajKaranraj
Trigger code will get excuted when insert/update/delete/undelete event is fired in that object, then trigger code will get excuted automaticaly. Trigger code are event based code, you don't need to call the code anywhere to execute.

In your code, when new Contact record is created in your org, then the trigger code will executed automaticaly.

Thanks,
http://karanrajs.com
sandeep sankhlasandeep sankhla
Hi Mukesh,

You can not execute same code in develiper console...because trigger fires when some event occurs..

Now Logic whihc is inside the trigger , you can execute from developer console...

Let me knwo what exactly you are trying to do..I would advise to go for testclass if you want to test ypur trigger ..test class is very simple to create adn validate our trigger..let me know if you need anything..

P.S. If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.

Thanks,
Sandeep
Salesforce Certified Developer 
This was selected as the best answer
mukesh gupta 8mukesh gupta 8
Hi Sandeep,

I am beginer in this field ,

I want to test my trigger value in debug mode.

Thank's

 
sandeep sankhlasandeep sankhla
Hi Mukesh,

If you simply want to debug the values, then you can go to setup and type debuglogs and select the user from which you are logged in and then there you can view all your debug statment whenever your code executes..

Thanks,
Sandeep