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

How we can get the current page ID in Trigger

Hi everybody,

      Actually i have checkbox field in my child record Here my requirement is the recent record should be active. For Example:I have 2 records in parent object under that one record have 3 childs and  the 3 child record should be active for that i wrote a trigger that is working fine but my problem is it is taking the overall child records which is recent record then that is activating the checkbox but i need 0ne parent record under 3 childs are there i want 3 rd record should be activate at the same time the second parent record have 3 childs here also the 3rd record should be activte. Totally i need 2 activate child records for that object.

Here i am implemented the trigger i know i am not writing any query on parent object but how to write i don't know that's reason i am posting here

trigger  ActivateSpecificationSheet on Specification_Sheet__c(before insert) {
    for(Specification_Sheet__c ssh : Trigger.New){
        ssh.Is_Active__c = true;
     List<Specification_Sheet__c > updssh = New List<Specification_Sheet__c >();
     List<Specification_Sheet__c > sshlst = [select id,name,Is_Active__c,Sales_Order_LineItem__c from Specification_Sheet__c where Is_Active__c = true ];
        for(Specification_Sheet__c ssh1: sshlst){
        update updssh;


Can any one suggest me please help me out......


When a trigger is initiated, you will get an array of records in the and Trigger.old objects.
You can iterate through those and get the Id, plus the other fields on that record.

for example:

trigger testAccountTrigger on Account (after insert, after update){

     for(Account a:{
        System.debug('id is: ' + a.Id);
        System.debug('name is : ' + a.Name);

I believe, this was helpful.