The syntax you posted above is using “Page Assignments”, which is a way to dynamically load a Skuid Page based on configured Page Assignments. If you want to just load a specific page, do this:
Can you explain a bit more about why you need to create a REST service class? A little context here will help me recommend an ideal solution. There are several different ways to invoke Apex logic from Skuid, and calling a REST service is one way but it is not always the best way. Another option is to expose your Apex logic as an Apex Invocable Method, and then you can invoke that method via a Skuid Page using a Data Source Action, which can be done completely declaratively from your Skuid Page.
Hey Zach, We used REST to allow SKUID to access multiple Apex classes that build and encrypts the url that is sent to our remote server. Got this all working in Skuid but now I am trying to figure out how to call the REST service within the VF page that is called from a custom button on the Account record. Was not sure what is the best way to call the WS. Thanks, Michael
Okay, so the easiest way to get this setup without writing any code is to use a REST Model. REST Models allow you to make calls to REST API’s and return the results into a Skuid Model. For example, if you configure a Read-Only REST Model that makes a GET request, you can just have a button in your Skuid Page call Skuid’s “Query Model” Action, and that will cause a GET request to be made to your REST API, with the results then being injected into row(s) in that Skuid Model. You can then easily display the results or use the results using Skuid Model functionality.
Expand the “Headers to send with every request” section, and click the little box that says “Click to open the Actions menu”, then click “Append”, and enter “Authorization” in the left and “Bearer {{$Api.Session_Id}}” in the right.
Click Save.
Now, go back to your Skuid page, and:
Add a new Model.
Select REST as the Data Source Type, and then select your Data Source Name.
You can leave the Model as “Read-Only” for now. UN-CHECK “Load Model Data on Page Load”.
Enter the relative URL to your Apex REST service, e.g. “/services/apexrest/MyAwesomeApexRestClass”. If your Model URL requires dynamic values, you need to define a merge parameter using {{ }} brackets, e.g.
If you have URL Merge Parameters, then when you go to select “Fields” or “Path to Contents”, Skuid will prompt you to enter sample values for those URL Merge Parameters, and then save these with the page so that you don’t have to use them again.
Now, if you REST Service is going to return you a simple object with a few key/value properties, e.g. { url: "some-url} }, or an Array of objects, then you can move right over to “Fields” and select the “url” field and add it to your Model. However if your REST service will be returning an a nested Object, e.g. { some: { deeplyNested: { foo: “Bar”, “url”: "some-url } }, you’ll need to first select “Path to Contents”, and specify the “path” through the nested tree to where your target Fields are located, e.g. click on “some” then click on “deeplyNested”.
Finally, if you have URL Merge Parameters, e.g. the {{bar}} and {{name}} described in step 4, then you’ll need to add a “URL Merge Condition” to your Model corresponding to allow dynamic population of the URL Merge Parameters. Click to create a URL Merge Condition for each unique parameter, and then select the corresponding parameter. For each URL Merge Condition, change “State” to be “Filterable Default Off” and leave value blank, unless there’s a default value that’s appropriate, in which case you should have State be “Filterable Default On” and enter a value.
Now, in your button’s code, you can use the “Activate and Set Condition” Action type to dynamically set the value of the “foo” and “bar” URL Merge Conditions, and then call Query Model to actually invoke the REST API request.
Zach, That’s an awesome write up and I believe I have most of that configured as you have listed. So how do I initiate a call from a Salesforce Button ? Just not sure of the syntax since I am using the @RestResource annotation in my Apex Class.
Sorry if I’m having trouble pinpointing exactly what you’re trying to do, are you saying that you are trying to take the user to your Skuid Page from a Salesforce custom button that’s on a standard Salesforce Account record detail page? If that’s the case, you just need to have the Custom Button navigate the User to your Visualforce Page, e.g. with something like this:
The Id of the context account record will automatically be sent in the URL.
NOTE: In order for your Visualforce Page to appear in the dropdown of Visualforce Pages here, it will need to have standardController=“Account” .