0

I am using SharePoint 2013 workflow. I am in the Initiation form when my my users clock the Start button to start the workflow. I am using JSOM to start the workflow but since I am on the Initiation form, I don't know the URL of the page. I do know the list (pages) and the the list id (2).

Can someone help me retrieve the list id's url using JSOM?

Thanks

Tom

user3556527
  • 51
  • 1
  • 5

1 Answers1

0

How to get Page Url in Initiation Form page:

var listId = getParameterByName('List');
var itemId = getParameterByName('ID');

var ctx = new SP.ClientContext.get_current();
var web = ctx.get_web();
var list = web.get_lists().getById(listId);
var listItem = list.getItemById(itemId);

ctx.load(listItem);
ctx.executeQueryAsync(
    function () {
       var itemUrl = listItem.get_item('FileRef'); 
       console.log(itemUrl);
    }, 
    function (sender, args) {
       console.log(args.get_message());
    }
);

,where

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, " "));
}

is intended for retrieving parameter from query string

Source

Community
  • 1
  • 1
Vadim Gremyachev
  • 57,952
  • 20
  • 129
  • 193
  • I would recommend How to: Retrieve List Items (http://msdn.microsoft.com/en-us/library/office/ee534956(v=office.14).aspx) as an introductory article – Vadim Gremyachev Apr 29 '14 at 20:05