Button to redirect to another page with parameters based on field values

  • 2
  • Question
  • Updated 6 years ago
  • Answered
To generate a DrawLoop document, I want to make a button that does this:
Where "ID" is the SF record ID of a record currently in use by my model.

When I tried to put this into a simple redirect button (without the "window.open") it interpreted my curly braces as literals. Is there a different syntax I would use to it that way?

Alternatively, I should be able to make this out of a snippet, but what is the syntax to retrieve specific field values of specific records in the models on my page (and the Session ID) in the javascript?
Photo of Peter Bender

Peter Bender, Champion

  • 6,296 Points 5k badge 2x thumb

Posted 6 years ago

  • 2
Photo of Zach McElrath

Zach McElrath, Employee

  • 53,784 Points 50k badge 2x thumb
Official Response
You'll need to tell Skuid to perform a merge on this URL in the context of your record.

There are several Skuid API methods you can use to do this, but if you have a Model and Row in context, as you will when making a custom snippet to use in a PageTitle button, you should use the "mergeRow" API method of the Skuid Model object, which takes as its arguments a row to use as the "context" for the merge, and then a merge template, such as your URL.

Here is the signature for the mergeRow method:

Model.prototype.mergeRow = function(row,template,options) {}

And here is an example that should work for your scenario:

// A PageTitle button
// should provide these variables in its arguments
// when you're using a custom snippet

var params = arguments[0],
model = params.model,
row = params.row;

var url = "/apex/loop__looplus?eid={{Id}}&sessionId={{$Api.Session_Id}}&autorun=true";
var merges = skuid.$('<div>').append(model.mergeRow(row,url));