0

So I came across the following post on Filter a list view using URL parameters, which is sort of what I was looking for but not at all at the same time.

I have a custom DataTable on a SharePoint Web Part Page that is very complex and already has certain custom filters applied to limit what the user can see based on the group they are in (if they are a Task Assigner, they can see everything. If they are an Assignee, they can only see items that include their name). I was able to do this and apply to the filter by using SPServices, to get the current user title and match it to the items in the table.

When a task is assigned, an email is sent(via workflow) to the assignee and includes a link to the current task table, but the table could show more than one current task. I want to send a link to the user that only shows the task they were just assigned. Is there a way I can apply this parameter to the page link, then be able to grab that parameter with JavaScript to apply to my custom filter?

UPDATE/EDIT:

I forgot to include this in my first part of the post, but I need to append it dynamically as it is a flow, not me sending out an email. At the bottom of my workflow there is a link to the page, would I be able to dynamically add the parameter to the URL in Designer, or even Power Automate if I switch to that?

1

Assuming you are using SP 2013 workflow, you can use Replace Substring in String action to replace a particular substring with another substring.

For example: You can create a string variable to store your URL like:

http://server/site/sitepages/MyCustomPage.aspx?MyCustomParameter=[MyCustomValue]

Then you can use above action to replace [MyCustomValue] with the actual value.

Check example given at: SharePoint Designer 2013: Replace Substring in String Action


Then you can read value of MyCustomParameter parameter using JavaScript on your SharePoint page & then apply filtering in DataTable as per your requirements.

Check below threads to understand how you can read query string parameter:

  1. How can I get query string values in JavaScript?
  2. How to get the value from the GET parameters?
6
  • So, from my understanding in Replace string with string in string (Output to Variable: output ). I store the url http://server/site/sitepages/MyCustomPage.aspx?MyCustomParameter=[MyCustomValue] in the first string of the action, then in the second string I select the current item --> list item id and for the third string, I enter [MyCustomValue]. Or do I have that backwards?
    – BeerusDev
    Sep 15 '21 at 14:53
  • Use it like: Replace [MyCustomValue] with current item --> list item id in string variable (http://server/site/sitepages/MyCustomPage.aspx?MyCustomParameter=[MyCustomValue]) Sep 15 '21 at 15:04
  • 1
    Works like a charm!
    – BeerusDev
    Sep 15 '21 at 15:07
  • Is this possible in a MS flow?
    – BeerusDev
    Sep 16 '21 at 18:06
  • I initialized the variable, named it TaskUrl. Type = string. Then put the http://server/site/sitepages/AllItems.aspx?ID=[MyID]. Then the next action I chose compose, and selected a replace function replace(variables('TaskUrl'), '[MyID]', triggerOutputs()?['body/ID'] ) and it tells me that I cannot replace a string with an integer?
    – BeerusDev
    Sep 16 '21 at 18:29

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.