Sharepoint 2013 app custom action - how to get parameters using JavaScript
-
11-12-2020 - |
Domanda
I'm learning to write SharePoint 2013 applications. I added menu item custom action, and now I'm trying to add some functionality to App.js. Custom action contains the following code:
<UrlAction Url="~appWebUrl/Pages/Default.aspx?{StandardTokens}&SPListItemId={ItemId}&SPListId={ListId}" />
And I'm trying to get parameters like "SPListItemId" and "SPListId" in App.js. I found the following code:
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
I'm calling this function like, but it doesn't work:
var SPListId = getParameterByName('ListId');
Please tell me where is my mistake.
Soluzione
You need to use
var SPListId = getParameterByName('SPListId');
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange