Button on form for an API request

  • 0
  • 1
  • Question
  • Updated 1 year ago
  • In Progress
I'm trying to add a button to form that when clicked will send certain form elements through a REST api to post to a Salesforce form.

Currently, I am only able to transfer data using a webhook which transfers the date any time the record is added or modified. I'd like to be able to send the POST command when the button is clicked rather than when the record is saved.
Photo of Austin Thomas

Austin Thomas

  • 70 Points

Posted 1 year ago

  • 0
  • 1
Photo of Matthew Neil

Matthew Neil

  • 31,438 Points 20k badge 2x thumb
A post command can be done in a formula url with a javascript command like so;

"javascript:$.post('DestinationURL').then(function(res,code) {console.log(res,code);window.location.reload()})"

I use the console log to see if it goes through without errors.

your 'DestinationURL' will be the payload for the salesforce form.  

Keep in mind that this will want to refresh the page, so any unsaved data might get lost.  So you will want to plan for that, and come up with some other approach.