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
SS KarthickSS Karthick 

Passing record id and group id

Hi folks,
          Can anyone tell me how to pass the group id and record id from trigger to apex class
like my apex class is 
Public static passMethod(Id recordId,Id groupId)

Please Help!
Best Answer chosen by SS Karthick
Gigi.OchoaGigi.Ochoa
Can you provide a little more information on what you are trying to do?  What do you mean by group Id?  What group(s) the current user belongs too?  Some lookup field from you object?  


Is this what you are looking for?
for(SObject ojb:trigger.new){

    Id groupId = ..... code to determine group Id....

    SampleClass.method(obj.Id, groupId);
}

All Answers

Grazitti TeamGrazitti Team

Hi Karthick,

Sample Code:

Trigger:

trigger Sample on Opportunity (before update, before insert) {
    if (Trigger.isInsert) {
        SampleApexClass.SampleMethod(Trigger.new);
    } else if (Trigger.isUpdate) {
        SampleApexClass.SampleMethod1(Trigger.new, Trigger.old);
    }
}

Apex Class:

global class SampleApexClass () {
    global static void SampleMethod(List<Opportunity> NewOpps) {
        /* trigger code*/
    }

    global static void SampleMethod1(List<Opportunity> NewOpps, List<Opportunity> OldOpps) {
        /* trigger code*/
    }
}

So like this, you can fetch each newly inserted/updated fields value in your controller.


And don't forget to mark this answer as best, if answer this helps you :-)
--
Regards,
Grazitti Team
Web: www.grazitti.com

SS KarthickSS Karthick
Hy how to pass only the group id to apex class
Gigi.OchoaGigi.Ochoa
Can you provide a little more information on what you are trying to do?  What do you mean by group Id?  What group(s) the current user belongs too?  Some lookup field from you object?  


Is this what you are looking for?
for(SObject ojb:trigger.new){

    Id groupId = ..... code to determine group Id....

    SampleClass.method(obj.Id, groupId);
}

This was selected as the best answer