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
KevinManxKevinManx 

Update object in future callout from trigger

I need to update a property in an object with a value from a callout.

 

Example:

When the user creates a new Contact I want to do a lookup for the address details and update the address as needed.

 

Current tested theory:

- In the 'After Insert' trigger I pass the Contact.Id to a future method that does the callout.

- The future method updates the Contact

 

The issue is that the Contact form shows the contact BEFORE the web call was done.

 

I don't have the Id if I do this process in the 'Before Insert' trigger.

 

Any toughts or suggestions?

SeAlVaSeAlVa

As no errors on the @future call will stop your trigger (before) from being executed,

why don't you call the @future method on after trigger?

DeveloperSfdc10.10DeveloperSfdc10.10

Yes ,It is not possible to get the record Id in before insert trigger.

When your trigger is working correctly in the after insert.Why you want to do that in before insert ?

Any specific requirement?

 

KevinManxKevinManx

This is how I am currently trying it. The issue I'm seeing is that the contact loads, after the user clicks "Save", without the change that was done in the @future method.

 

If I can't do the work in the 'before' trigger (which I had suspected) is there a way to force either a refresh of the form after the @future method had don it's work?

SeAlVaSeAlVa

Why don't you try making the changes on the trigger itself, instead of on a @future call?