Fitler/Query Question
Fitler/Query Question
Link to test case:
So I have been tasked with an oddly specific piece I need to add to the project I have been working on. I have a script running that when a new row is added to my DataTable (task list), it emails the user that the task is assigned to via a SP workflow. The table already filters to only show the current users tasks (active/inactive) on two separate tables, a current and complete table. In the email it 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 this possible via the custom search plugin? Or would I need something like a SharePoint url query/filter.
This question has accepted answers - jump to:
Answers
This. You need to specify in the url what items you would like to show in the table. You would then read that parameter and apply a search to the table that would reduce the result set to just that item.
Allan
@allan thanks!
UPDATE:
So I am passing a custom parameter into the URL that is getting emailed to the assignee, and I am getting the value like so:
This is at the top of my document.ready function, then I have the following search/filter function below where it shows the all the users items, but I want to customize it to where when they click the link sent with the URL param, it only shows that list item with the same ID (which I have as a hidden column in the table). But when the user visits the link that doesn't contain the param, still shows all of their tasks instead of the one where the item id matches :
To achieve what I mentioned above would I need a nested condition? something like:
I don't understand your requirement but you might want to change lines 7-9 to this:
Otherwise the if block in line 6 will always return true if
tableUserTitle == thisUserTitle
.Kevin
So the requirement is:
When the user gets the original email linking to the page, it will only show the table item which the itemID is the same as the paramId.get('MyCustomParameter').
If the itemID != the paramId.get('MyCustomParameter'), then I want it to show all of the items that are true when tableUserTitle == thisUserTitle
Something like this?
Kevin
That is what I want to be the case. But it is showing all of the list items. I console
After I created a new item, I console log the searchData[7] as well, and get the same result as queryString, but all results show. Not as intended... I create a new one with 59 as the item ID and query string.
It is still showing the item with 58 as the ID when I click on the 59 link. If I cross out the other condition and have only this,
it filters the table as itended
Glad you got it working.
Kevin
I didn't get it working. It only works with one condition? I am trying to recreate the issue in a fiddle to show you. I have two conditions that work at the same time, but when I remove the first one checking if user is a task assigner. the second and third which I included in my OP do not work together. It is either one or the other.... Kind of frustrating
Nevermind, I fixed it, trying to upload the example now
Here is my minimal reproducible example, as you can see it shows both table items when it should show one https://jsfiddle.net/BeerusDev/ku4hcwfp/53/
You have this:
Purely from a logic stand point the
temID != queryString &&
is not needed. It won't get to this point unlesstemID != queryString
is true because of the previous if statement. Remove it to help save processing cycles.In your test case
tableUserTitle == thisUserTitle
will always be true as both rows haveBeerus Dev
. Sorry, but I still don't understand the requirement.You have
queryString
andthisUserTitle
which you want to use to filter the table. You haveitemID
andtableUserTitle
columns in the table. Write down the rules of which rows will be displayed or removed based on comparing these values. Then write the if statements to match.Kevin
I will keep attempting. But I want the
itemID == queryString
to take the higher precedence over thetableUserTitle == thisUserTitle
. Because if theitemID == queryString
, I only want that matching item to show. It is pulling the substring from a URL parameter from a new task item created, and when emailed to the user. I only want them to see the one just created. But at any other time when they visit the page without the parameter, it shows all of their different current tasks. Sorry, I am trying to be as specific as possible.Side note, in my actual application I have two tables. Is it possible to apply a different filter to each table id? Because right now it is applying the same filter to both
Sounds like you need to check for the existence of the URL parameter in the search plugin. If it exists then check
itemID == queryString
. If not then checktableUserTitle == thisUserTitle
.See this thread.
Kevin
@kthorngren My brain doesn't like to function at max capacity this early in the morning. I don't know why I couldn't figure this out earlier. I was looking at the issue wrong.. So I have the following getting my queryString
if there is no parameter, then queryString is equal to null. So with the following code, the filter works as expected.