You need to use the “skuid:page” Visualforce component method of invoking Skuid, as opposed to the “Redirect” method.
See this tutorial for more details:
https://docs.skuid.com/v10.0.4/en/skuid/deploy/salesforce/visualforce/skuid-page-visualforce-compone…
Hey Zach,
Where do you reference the Skuid page in the VF syntax?<apex:page
standardController="Account" extensions="skuid.Redirects,MyController" showHeader="true" sidebar="false" readonly="true" docType="html-5.0" action="{!IF(canUseSkuid,'',redirect)}" title="New {!$ObjectType.Account.label}"> <skuid:page objectType="Account" actionType="New" />
</apex:page>
Thanks
M
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:
<skuid:page page="MySkuidPage"/>
Understood. For us to get Skuid to work in SF we have to create a Rest service Class. Is there standard format/syntax in Skuid to call a rest service?
Thanks for your time and patience.
M
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
Is it a GET / POST request? Does it take any query string parameters / POST body data?
It’s Get only.
Need to get field value off record and then appended to url prior to call to the server
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.
For an overview of using Skuid REST Models, see this tutorial: https://docs.skuid.com/v10.0.0/en/data/rest/
For connecting to Apex REST Resources using Skuid REST Models, see this tutorial: https://docs.skuid.com/v10.0.0/en/skuid/salesforce/apex/apex-as-rest.html
For connecting specifically to your current Salesforce Org using REST, here’s what you need to do:
- Go to Skuid Settings > Data Sources > New Data Source
- For Data Source Type, select “REST”, and enter a name such as “CurrentSalesforceOrgREST”
- For URL, enter your Salesforce org’s main URL, e.g. "https://acme.my.salesforce.com" or "https://na30.salesforce.com";
- For Authentication, put “No Authentication”
- 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.
“/services/apexrest/MyAwesomeApexRestClass?foo={{bar}}&sayhello={{name}}”
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.
Thanks,
Michael
Can you explain what you mean by “initiate a call from a Salesforce Button”? You are doing this from within a Skuid Page, correct?
Yes. But I need a way for the user to initiate the request from an Account record.
Thanks,
M
As far as I’ve understood, you should be able to just query the skuid model that you’ve built on your REST service.
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” .
Is this what you’re trying to do??
Totally over complicated this. here is the VF page that resides on the Account page. Thanks for all your help Zach.
<apex:page
standardController=“Account”
extensions=“skuid.Redirects”
action=“{!redirect}&page=SkuidPage”>
</apex:page>