Requested business process: before insert trigger runs to validate email before insert (using managed package) > process builder runs > process builder calls flow to [do stuff].
To make a callout I call an @future method in a class from my trigger, executing a method from managed package (listed as global).
@future method runs successfully and updates managed package fields, but not my custom fields on the lead.
I created static String fields in the class and set them during the @future method run.
I have created other static methods to return the static variable value (return myClass.variable).
In my before insert trigger, I am using the static class methods to assign values like l.custom_field__c = myClass.getVariable().
I added debug statements to the trigger, and the lead fields are coming back null, thus the lead fields are not being populated by calling the class methods.
I have a feeling this is related to the transaction context (from trigger I call class callout method > from @future method set static variable values then call static method getters from trigger to assign the values back to the lead before insert).
Am I correct in thinking by the time my lead trigger calls the static getter methods, the transaction context is done, so they are back to null?
If that's correct, how can I get those values to the lead fields in the trigger?
I can post my code if that will help (although it will be ugly - novice developer). Otherwise, I feel like there is something small I am missing!
Thanks
question from:
https://stackoverflow.com/questions/65940801/setting-values-on-a-before-insert-trigger-from-apex-class-static-variables 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…