When working with ShortPoint connections, you can either enter a custom URL or have one automatically generated when you select a local data source. This guide shows you how to use the Change Parameters feature to dynamically change your connection's URL by editing, adding, or removing parameters as needed.
This feature is currently available in the following ShortPoint connection types:
- REST API
- Site News
- Org News
- Hub News
- Current Site
- Other Site
- Site URL
- People Search
- RSS Feeds
- Web Service XML
- Microsoft Graph API
Prerequisites
- You have the latest ShortPoint SPFx version installed on your SharePoint site.
- You are a ShortPoint Designer with an active license.
How does the Change Parameters feature work
You might want to dynamically change URL parameters in your ShortPoint connections based on real-time data, such as the currently logged-in user. However, you may face different limitations depending on your connection type:
- Local data source: The connection URL cannot be edited directly
- REST API and Microsoft Graph API connection: While you can edit the full URL, manually updating parameters for dynamic data isn't practical
This is where the Change Parameters feature becomes useful—it lets you automatically adjust parameters regardless of your connection type.
Here is an example REST API connection URL:
The URL Query Parameters are represented by the value beginning after the question mark (?) in the URL, which in our case would be:
?$select=Id,Title,Body
If you would like an extra parameter to be appended to the URL, for example:
$filter=userId eq 12
You need a way to edit the URL. Since you can't edit the URL directly, you'll need to use the Change Parameters field instead. You can add custom JavaScript code that extracts the current URL parameters as a JavaScript string, modifies the parameters as needed, and reattaches the updated parameters to the URL before connecting.
It will process the URL parameters so that the final URL becomes:
/sap/fiori/shortpointwidgetbeta/destinations/shortpoint-sharepoint_announcements/_api/web/lists/GetByTitle('Announcements')/Items?$select=Id,Title,Body&$filter=userId eq 12
The feature takes a single argument called parameters, which contains the URL parameters as a string. If you leave the Change Parameters field empty, the function will extract the existing URL parameters without making any changes. The default value is:
return parameters;
In the example provided above, the value of the parameters argument would be:
?$select=Id,Title,Body
Since the parameters argument is a string, you can use standard string manipulation methods to modify it. In the simplest case, you would just need to add (concatenate) the following to the end of the initial string:
$filter=userId eq 12
That means we need to apply the following JavaScript code. Please note that we are adding an ampersand (&) since we now have multiple parameters, and & has to be used as a separator.
parameters += '&$filter=userId eq 12'; return parameters;
The updated URL query parameters will be displayed at the top of the Change Parameters function once you click on the Connect button:
Here is another use case:
Modifying URL Parameters
Here are the steps that you need to take to be able to apply dynamically modified URL parameters in ShortPoint Connections:
Step 1: Set up your connection
- Switch to Grid Mode (ShortPoint Connect is currently only available in Grid Mode).
- Open the Design Element settings and go to the Connect tab.
- Select a connection type.
- Ensure that all the required fields are completed to establish a successful connection.
Step 2: Enable Advanced Settings
- Scroll down and look for the Enable Advanced Settings toggle. Toggle it on.
Step 3: Input your custom parameters
- In the Change Parameters field, input your new parameters.
Step 4: Hit Connect
- Once done, click the Connect button.
You can then proceed to map the data you want to display in the Items tab and update your Design Element.
Now, you can insert dynamic parameters into your URL before connecting using the Change Parameters feature in ShortPoint Connect.
Related articles:
- How to Add an HTTP Header to ShortPoint Connections
- Modify the URL Path Function for Your ShortPoint REST API Connection
- Map Results Function for Your Custom ShortPoint REST APIs