2

I have a usecase which can be either achieved by 1)create a custom button
2)add javascript
3)call apex global webservice class [all apex function to be called from JS should be global webservice]which has the logic of updating database

OR

1)create a custombutton
2)invoke VF page
3)VF extension controller handles logic

Which is a best way to do this?I went for second thinking,more webservices might not be a good thing.But does anyone know what should be the approach to be taken in such cases

2 Answers 2

1

Some time ago, I have found that the use of JavaScript in the custom button is good only for simple tasks (here i mean the standard page layout). For example, to open popup windows or alerts. If you runs complex task in backend, the page remains "frozen" for this period and it is difficult to perform the callback functions.

It is much better for me when i use an extra page for such tasks. Over there i am "the king" and can control usually all i need.

My conclusion: if possible use an extra Visualforce page and controller.

0

Why not doing all through visualforce page only.Even the custom button can directly call a visualforce .You may not need JavaScript at all.The action attribute of apex:page tag can be used to achieve the functionality

<apex:page action={!hello} controller="{!redirectctrl}"/>

You can get rid off javascript code also to keep it complete native .

Edit after question changed:

a native solution is always better than java-scripting as the flexibility we gain is huge and no more browser dependency will occur .

1
  • It was my mistake in question.i actually did create custom button,and specified behaviour as VF..have edited query now.thanks for pointing out
    – sfdc99999
    Commented Jul 17, 2013 at 11:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .