To generate a DrawLoop document, I want to make a button that does this: window.open(“/apex/loop__looplus?eid={{Id}}&sessionId={{$Api.Session_Id}}&autorun=true”) 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?
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.$('').append(model.mergeRow(row,url)); window.open(merges.text());
Thanks for the help. So, the code that you provided that is what the snippet should look like, and just referencing that snippet from a page title button should automatically provide the right parameters to the snippet, is that right? When I do this, I get a page that only shows the following error message:The name can only contain underscores and alphanumeric characters. It must begin with a letter and be unique, and must not include spaces, end with an underscore, or contain two consecutive underscores. The URL provides a clue, probably: https://skuid.na14.visual.force.com/apex/[object%20Object]
Peter, I have updated my answer — the last two lines of the Snippet need to be changed. The “mergeRow” method actually returns a result that is suitable for inclusion in the page’s DOM, not a plain text string. So, after appending this content to a temporary DIV, you can grab the internal text contents of the DIV, and this is a string, suitable for inclusion in a URL.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.