I have a requirement where, on changing a particular field value of an account record from Lightning page layout, I have to make a callout. If the response from the callout is not successful, then the record shouldn't be saved, and it should display an error message.
Here, I am using Process Builder and using the invocable method, I am calling a REST API. In this case, I am getting this error message:
'You have uncommitted work pending. Please commit or rollback before calling out'.
But if I use a future call, then it will be a new transaction; the record will always save irrespective of the success or failed response.
How can I achieve this requirement criteria to make it look like a synchronous transaction? Appreciate your inputs.