I'm developing a Sharepoint 2013 Add-in, and I need to retrieve the query string of the original request.
Users are linked to our add-ins from emails and we need to provide some context. The add-in is requested like this: https://x.sharepoint.com/MyAddIn?p=10
Is it possible to retrieve the value of p in my add-in?
The information within a query string is passed to your website and stored in the server log files where it can be saved as embedded data and used for a variety of applications.
SharePoint search supports Keyword Query Language (KQL) and FAST Query Language (FQL) search syntax for building search queries. KQL is the default query language for building search queries. Using KQL, you specify the search terms or property restrictions that are passed to the SharePoint search service.
CAML is an XML-based language that is used in Microsoft SharePoint Foundation to define the fields and views that are used in sites and lists.
You could use the following code snippet:
Uri myurl = new Uri(Request.QueryString["SPHostUrl"]);
string param1 = HttpUtility.ParseQueryString(myUri.Query).Get("p");
or use
string param1 = Request.QueryString["p"];
If you want to this via JS, then go on with this
function getQueryStringParameter(paramToRetrieve) {
var params;
var strParams;
params = document.URL.split("?")[1].split("&");
strParams = "";
for (var i = 0; i < params.length; i = i + 1) {
var singleParam = params[i].split("=");
if (singleParam[0] == paramToRetrieve)
return singleParam[1];
}
}
var sProp = decodeURIComponent(getQueryStringParameter("StringProperty1"));
document.write('Value of StringProperty1 : ' + sProp + '</br>');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With