Find your content:

Search form

You are here

How to get values from class to trigger

 
Share

I'm having a class with a picklistfield (field1) and in that I'm getting values as

string field1;
Public string getfield1(){return field1;}
public void setTemplate(string field1){this.field1 = field1;}
       public list<selectoption> gettempname()
      {
          list<selectoption> option = new list<selectoption>();   

          for(object__c design : [select name from object__c limit 10] )         
             option.add(new selectoption(design.name,design.name));
             return option;     
     } 

and using this in a query as

object1__c emailcontentinfo = [select field12__c from object1__c  where object__r.name =:field1 limit 1 ];

now I'm writing a trigger on another object(object3).In this need to get the values of field1....How can I get it...H


Attribution to: Eagerin Sf

Possible Suggestion/Solution #1

If you make this a static property, it will be available for the duration of the transaction, thus you can refer to it in your trigger. E.g. assuming your class is MyClass:

public static string field1;
Public string getfield1(){return MyClass.field1;}
public void setTemplate(string field1){MyClass.field1 = field1;}

Then in the trigger you can have:

object1__c emailcontentinfo = [select field12__c from object1__c  where object__r.name =:MyClass.field1 limit 1 ];

Attribution to: Bob Buzzard
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/4437

My Block Status

My Block Content