1

I'm trying to add a button to a SharePoint list that, when clicked, will navigate the user to a new web page and send a parameter from the current list.

I think I have fond a way of doing this, at least there are a set of options in the menus in SharePoint which seem to be exactly what I want, but I simply cannot get it to work. What I am doing is as follows

  1. Creating a new basic list with only three text columns
  2. I'm then creating a fourth column which will contain the button
  3. I'm creating the button by selecting 'Design' -> Insert Control' -> 'Form Action Button'
  4. Next I right click on the button and choose 'Form Actions...' from the drop down menu
  5. A window then pops up and I select the following - 'Navigate to Page' -> then click Settings -> then click Browse -> I then select the page I want to move to -> then I click Parameters -> then I click on the 'Add' button and chose the name of the Parameter.
  6. Then Click OK to close down all the windows.

I end up with the following, Where 'Progress' is the name of my parameter

/EditForm.aspx?@Progress={@Progress}

But when I try this in IE it sends me to the page but just displays the text above for the parameter value, it does not send the actual value in the parameter.

Can anyone say what is wrong with the above please. I'm relatively knew to this so apologies if I'm doing something stupid (which is definitely possible).

Note : it might be worthwhile saying that I CAN get this to work in Sharepoint Designer if I right click on one of the actual text values in one of the columns and select 'Format Item as' -> and then 'Hyperlink To' -> and then 'choose 'Edit Form'. But I can't get it to work with the button.

-------------------------------------------

Editing my original post because I don't have enough points to add a comment and I don't have any other way of replying :-(

OK I tried Amal's suggestion but it still doesn't seem to be working. I think their must be a specific step I'm not doing correctly, I'm trying the following...

(1) right clicked on the button and selected 'Navigate to Page' then clicked on Settings.

(2) Double clicked on Lists in the files window. This gave me...

    https://..../Lists/

(3) Then double clicked on my list and then selected allitems.aspx. This gave me...

    https://..../AllItems.aspx

(4) I then placed the cursor at the end of aspx. and clicked on 'Parameters. Then I clicked on 'Insert Field Value' and selected 'xls:Progress'. This gave me (which didn't look right)...

    https://..../AllItems.aspx{@Progress}

(5) I then clicked on 'fx' and selected Rows->Row->Progress. This gave me...

     https://..../AllItems.aspx{@Progress}{$thisNode/@Progress} 

(6) I tried this (in hope more than anything else) but it failed with a page not found, I guess because the URL is not formed properly. So I changed it manually to say this....

     https://..../AllItems.aspx?Progress={$thisNode/@Progress} 

But the above gives me my original problem where its just displaying the above string and not the values.

Any help would be really appreciated.

Regards, Martin.

0

In Step 5.

After Clicking Add, you can see a button 'fx'. Click on that button and select the field you want to pass.

After selecting the field the URL will be something like

http://.../default.aspx?Progress={$thisNode/@Progress}
  • Thanks for the response Amal. I have tried it with the URL you suggest but the page sends me to the following URL... http://..../Allitemsg.aspx?Progress=%7B$thisNode/@Progress%7D – Martin Oct 31 '14 at 14:44
  • That means you havent selected the correct page in the first place. Select the proper page using "Navigate To Page".. Then Add Parameter.. Then select field using Fx button – Amal Hashim Oct 31 '14 at 14:51
  • Martin did you ever find a solution to this? It would be so appreciated. – Mike Rooker Jan 31 '17 at 2:12
0

This definitely isn't an ideal solution, but it works.

You can have javascript run by selecting 'Navigate to URL' in Step 5. For example, you can place javascript: alert("it works"); in the field.

You can also query list data with javascript. So:

var ctx = new SP.ClientContext.get_current();
var currentListGuid = SP.ListOperation.Selection.getSelectedList();
var currentWeb = ctx.get_web();
ctx.load(currentWeb);

var currentList = currentWeb.get_lists().getById(currentListGuid);
ctx.load(currentList);

var items = SP.ListOperation.Selection.getSelectedItems();

var listitem;
for (k in items) {
    listitem = currentList.getItemById(items[k].id);

    ctx.load(listitem);
    ctx.executeQueryAsync(Function.createDelegate(listitem, function () {

        progress = escape(listitem.get_item("Progress")); //"Progress" is your (internal) column name

        window.open('/EditForm.aspx?' + 'progress=' + progress);
    }),null);
    break;
}

Minify that (so that it's one line), and add that after javascript: in the 'Navigate to URL' field.

It'll look something like this:

enter image description here

0

I would use CSR to render the button for each item, check this link.
Here a short example:

RegisterModuleInit("anIdForRegisteringYourModule/imUsedToUseTheAbsolutePathOfTheJsFile", CustomView);
CustomView();

function CustomView() {
    var options = {};
    options.Templates = {};
    options.Templates.Fields = {
        'ColumnYouWantToCustomize': {
            "View": functionToCall
        }
    };
    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(options);
}

function functionToCall(ctx, field, listItem, listSchema){
    var yourVar = listItem[field.Name];
    return '<button defineItHowYouNeed attr="'+yourVar+'" onclilck="callAnotherFunction("'+yourVar+'")"/>';
}

The code is not tested, but should work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.