You need to sign in to do that
Don't have an account?
debiken88
Raising an exception on a callout by trigger, updating a hidden field on the object?
Hey Everyone,
I have a situation I'm trying to figure out a work around for. So I have a webservice returning JSON data that is working very well, my apex code calls out to the webservice, returns the data and I update the appropriate fields. In one instance, I need to go get the latest data when a field is changed on the account object. So I created a trigger that invokes the apex class, calling out to the the webservice with an @future method (which in turn updates the account object). If the user has entered an incorrect value, the JSON data returns nulls. We don't know they've entered an incorrect value until the callout hppens. So I'm trying to figure out a way to notify the user that the data entered wasn't valid. I was thinking I would update a hidden "invalid data" field on the account object and raise an error on an update trigger, but this seems like it could be problematic.
Anyone have any ideas? I would be REALLY grateful!! :)
I have a situation I'm trying to figure out a work around for. So I have a webservice returning JSON data that is working very well, my apex code calls out to the webservice, returns the data and I update the appropriate fields. In one instance, I need to go get the latest data when a field is changed on the account object. So I created a trigger that invokes the apex class, calling out to the the webservice with an @future method (which in turn updates the account object). If the user has entered an incorrect value, the JSON data returns nulls. We don't know they've entered an incorrect value until the callout hppens. So I'm trying to figure out a way to notify the user that the data entered wasn't valid. I was thinking I would update a hidden "invalid data" field on the account object and raise an error on an update trigger, but this seems like it could be problematic.
Anyone have any ideas? I would be REALLY grateful!! :)
If this works you might have to look at the following posts for more information
http://salesforce.stackexchange.com/questions/18238/check-that-criteria-are-met-in-a-before-insert-trigger
https://developer.salesforce.com/forums/ForumsMain?id=906F00000009D9XIAU
I do not think there is any other way around to do this other than the trigger and workflow rule combinations. Also the before and after triggers are executed if the workflow rule is executed in between, you might also consider this situation. But either ways it will not be immediate if that is not the concern.
Just a couple random out of the box ideas... If your user data entry workflow is simple enough you could replace it with a flow and have the callout done synchronously with an apex plugin before the record is updated.
Another possibility could be a visualforce page and a controller extension that does the callout and giving the user feedback before the record is saved.