You need to sign in to do that
Don't have an account?
Michael Salgo
Custom Button Advice Regarding RESTful Web Service Call and Local Value Setting
Hi All,
I am looking to implement a custom button which will be visible on the detail page of an object - let's say the Contacts object. When this button is pressed, I want to have data go from the Contacts record through a RESTful web service call and have a unique value returned. The user would not be redirected to a new page and the returned value would be used in setting a custom field on the Contacts screen.
Is something like this possible or do I have to create a middle VisualForce layer which will take information from a referenced Contact ID, pass data along through the web service, set and save the returned value, and then redirect the user back to the referenced Contact ID?
Ideally I would like this process to work no matter the Salesforce object if at all possible.
Thanks,
-Michael
I am looking to implement a custom button which will be visible on the detail page of an object - let's say the Contacts object. When this button is pressed, I want to have data go from the Contacts record through a RESTful web service call and have a unique value returned. The user would not be redirected to a new page and the returned value would be used in setting a custom field on the Contacts screen.
Is something like this possible or do I have to create a middle VisualForce layer which will take information from a referenced Contact ID, pass data along through the web service, set and save the returned value, and then redirect the user back to the referenced Contact ID?
Ideally I would like this process to work no matter the Salesforce object if at all possible.
Thanks,
-Michael
I would suggest you to use Apex In Ajax concept to accomplish this instead of a page.,
All you need to do is to write an Apex Class with visibility as Global and a method in it mentioned as webservice which has all the logic you need. Now from a java script based custom button on standard page, you can invoke this method and get response from that method.
For more info, take a look at below link:
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_and_ajax.htm
Hope it helps.,
Thanks,
balaji
All Answers
I would suggest you to use Apex In Ajax concept to accomplish this instead of a page.,
All you need to do is to write an Apex Class with visibility as Global and a method in it mentioned as webservice which has all the logic you need. Now from a java script based custom button on standard page, you can invoke this method and get response from that method.
For more info, take a look at below link:
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_and_ajax.htm
Hope it helps.,
Thanks,
balaji
Thank you.,
If i understand correctly, you are asking whether you can update a field that belongs to same record from which the button is clicked?
I personally dont prefer to scatter the logic, instead i would do a callout from the method , update the record as you need it as anway we are going to pass the record id and other necessary parameters to this method, after the logic is complete just return the success or error message and use the button to refresh the page if it is success so it displays the updated field value or just displays an alert with error message so that the user will be notified about the error
Hope it helps.,
Cheers :).
Thanks,
Balaji
Cheers.,
Thanks,
Balaji