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
AmarjeetAmarjeet 

future method usage creating delay in field update

Hey ,I am using future method in one apex class which is used to calaculate and update some field value. But, I am getting the value updated after few secand/ few refresh. What can be the solution for this to update the field in the excat time without removing the future method?

Thanks in advance
Best Answer chosen by Amarjeet
Raj VakatiRaj Vakati
I dnt see any options  from trigger as its a limitation ..  

You won't be able to make the callout synchronously from the trigger, because you would be holding up the transaction (and thus locking records etc) for a potentially long period of time.

 If you want to make it as real time .. create a VF page button and process the API call on the on click button .. 

 

All Answers

Raj VakatiRaj Vakati
If you want to do it real time you need to use the trigger .insted of calling the logic in feature ..  If you are making callouts from the trigger you need to use feature methods 
AmarjeetAmarjeet
Hi Raj ,
We are calling the future method from a trigger and we have to use future method bcoz of some other dependency. As we now for asynchronous process we can not control the time and getting the value populated after specific refresh/ delayed what can be the solution ?

Thanks
Raj VakatiRaj Vakati
I dnt see any options  from trigger as its a limitation ..  

You won't be able to make the callout synchronously from the trigger, because you would be holding up the transaction (and thus locking records etc) for a potentially long period of time.

 If you want to make it as real time .. create a VF page button and process the API call on the on click button .. 

 
This was selected as the best answer
AmarjeetAmarjeet
Okay Thanks a lot but what your views on Streeming API in this case, Can we use that?
 
Raj VakatiRaj Vakati
You can use the streaming API .. even if you use the streaming API you need to write the VF page and moreover, you have to do a hard refresh to show the changes on front end .. 

instead of that, we can use the VF page ??


window.reload() ;
AmarjeetAmarjeet
But in this case we are using standard page , thats the issue .
 
Raj VakatiRaj Vakati
Even if you use the standard layout you can include the VF page layout