1

I have created a custom button on a record that calls onClick JS to update the record. I would like to call the same JS button's function, from a VisualForce page. The purpose for this is so that I only need to maintain the button in one place (config). I would rather stay away from inline JS, or Apex.

I have tried the below, with little success...

<apex:commandbutton styleClass="btn-action" action="{!URLFOR($Action.Application__c.Approve,Application__c.id)}" value="Approve"/>

Do I need to use actionFunction?

Any thoughts would be appreciated!

This image should help. In the "standard" button row, there is an Approve button. In the blue banner below (a visualforce page), there is an Approve button, which needs to perform the same task (a field update on the record).

proposed functionality

  • Please have a look on this It might help you. – salesforce Developer Aug 7 '17 at 6:51
  • Hey salesforce Developer, thanks, I saw this. I was really interested in using the Custom button alone, and have come to the conclusion that it may not be possible. Thanks for your two cents though! – TheMikeyBoosh Aug 7 '17 at 22:12
1

Just to mark this as complete, I was unable to find a definitive answer to the original question. In the end, I rewrote the JS in the VF Component/Class.

0

In this document it says "All objects support basic actions, such as new, clone, view, edit, list, and delete. The $Action global also references actions available on many standard objects." Based on which, Submit for Approval can not refer to Custom objects.

Alternatively you can try a inline javascript button that simply open up the approval process page as discussed in here

Good Luck!

  • Hi Chris, there seems to be a misunderstanding. The button only updates a filed on the record, and is not part of an approval process. The button's name is simply "Approve". The function inside this button is what i am trying to run from the VF page. – TheMikeyBoosh Aug 7 '17 at 2:24
  • @TheMikeyBoosh can you find the valid value of what you are planning to do with the $Action buttom from the SF document provided? – Chris Chen Aug 7 '17 at 2:30
  • Hi Chris, I could, if I wrote the JS from the record's custom, on the VF page. Basically, I just want to "press" the same button, that is on the record, but from a visualforce page, embedded in the same record. I have attached a screenshot above. – TheMikeyBoosh Aug 7 '17 at 2:39
  • What are you trying to do with the button if not "submit for approval"? – Chris Chen Aug 7 '17 at 3:03
  • Update a field. – TheMikeyBoosh Aug 7 '17 at 3:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.