# Follow URL with multiple filters applied

**URL:** <https://forums.knack.com/t/follow-url-with-multiple-filters-applied/17239>\
**Category:** Get Answers\
**Created:** [May 20, 2024, 7:02pm UTC](https://forums.knack.com/t/follow-url-with-multiple-filters-applied/17239 "2024-05-20T19:02:06Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Team](https://avatars.discourse-cdn.com/v4/letter/t/b5a626/32.png) [@Team](https://forums.knack.com/u/Team)\
**Post date:** [May 20, 2024, 7:02pm UTC](https://forums.knack.com/t/follow-url-with-multiple-filters-applied/17239/1 "2024-05-20T19:02:06Z")

</div>

Hi,

I have a page with a grid view for a logged in agency (table).  
this grid view displays for a logged in agency (table) for everyone of its consultants (table) a selection of matching jobs (table)

 ![image](https://us1.discourse-cdn.com/flex020/uploads/knack/original/2X/a/a91a4e3fc01cd4ab12c6e0aa05cbd0ff4ccbdad3.png)

The behavior I would like to get is that once you click on the job, you go to the specific job page AND the consultant filled in, in the drop-down. It is easy to get the job, however, I can’t find a way to also have the consultant filled in. As you can see, it goes to the right job. Without any consultant filled in by default.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/knack/original/2X/e/eaa58f1130288088f61bd904c37e592ad4e92029.png)

For reference, here you can find the relevant table diagram:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/knack/original/2X/f/ffbb53119981eb4c85213a6fd78c2baeface7c89.png)

---

<div class="post-metadata">

**Author:** ![StephenChapman](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/stephenchapman/32/1759_2.png) [@StephenChapman](https://forums.knack.com/u/StephenChapman)\
**Post date:** [May 20, 2024, 10:10pm UTC](https://forums.knack.com/t/follow-url-with-multiple-filters-applied/17239/2 "2024-05-20T22:10:18Z")

</div>

Hi @Team, unfortunately you can only link the form to one connection value, but you can use some JS to also add on a URL variable with the row’s Consultant.

In the below method, I update each link in the Roles field by adding on a [URL variable](https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&ved=2ahUKEwjc7OLrn52GAxUh8DgGHai4AuQQFnoECBkQAQ&url=https%3A%2F%2Flearn.knack.com%2Farticle%2Fz36i2it02b-how-to-use-url-variables-to-pre-populate-a-form&usg=AOvVaw3ZdAkppunRrd01TouhyDiT&opi=89978449) containing the row’s Consultant record ID, which passes to the form on the linked page:  
 ![url-variable](https://us1.discourse-cdn.com/flex020/uploads/knack/original/2X/a/a5b1e398409a8b2b2455ae34b5395e858ecdb388.gif)

**Requirements**

- Your grid of Consultants (`view_xx`)
- A Jobs many-many connection field on the Consultants table (`field_xx`)
- A Consultant connection field on the Agency Application table (`field_yy`)
- A form to add a Agency Application to the page’s Job (`view_yy`)

**Solution**

1. Insert the following code into your Knack JS section.

```auto
$(document).on('knack-view-render.view_xx', function(event, view, record) { //scene_66

  // Initialise constants
  const rolesField = 'field_xx';
  const applicantUserField = 'field_yy';
  const applicationViewKey = 'view_yy';
  
  // For each link in the Consultants > Jobs field
  $(`#${view.key} td.${rolesField} a`).each(function() {

    url = $(this).prop('href'); // Get the current URL in the link
    const userId = $(this).closest('tr').prop('id'); // Get the row's record ID
    // Build the URL variable object
    const object = {
      [applicantUserField]: [userId]
    }
    const json = JSON.stringify(object); // Convert the object to a JSON string
    const variableUrl = encodeURIComponent(json); // Encode the JSON string to be URL friendly
    newUrl = `${url}?${applicationViewKey}_vars=${variableUrl}` // Append to the existing URL
    $(this).prop('href',newUrl); // Update the URL

  });

});

```

1. Replace the view and field keys with the ones in your own app.

Let me know how that works for you!

---

<div class="post-metadata">

**Author:** ![Team](https://avatars.discourse-cdn.com/v4/letter/t/b5a626/32.png) [@Team](https://forums.knack.com/u/Team)\
**Post date:** [May 22, 2024, 7:18am UTC](https://forums.knack.com/t/follow-url-with-multiple-filters-applied/17239/3 "2024-05-22T07:18:00Z")

</div>

@StephenChapman I 100% appreciate your rigourous feedback!  
I’ll keep you posted on the progress.

---

<div class="post-metadata">

**Author:** ![Team](https://avatars.discourse-cdn.com/v4/letter/t/b5a626/32.png) [@Team](https://forums.knack.com/u/Team)\
**Post date:** [May 22, 2024, 7:31pm UTC](https://forums.knack.com/t/follow-url-with-multiple-filters-applied/17239/4 "2024-05-22T19:31:56Z")

</div>

@StephenChapman I’m unfortunately not getting there.

Showing you everything:

JS Code:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/knack/original/2X/4/4714f2002d472f1cace1c36e652fdaa4538befe0.png)

- Your grid of Consultants (`view_xx`)  

- A Jobs many-many connection field on the Consultants table (`field_xx`)  

- A Consultant connection field on the Agency Application table (`field_yy`)  

- A form to add a Agency Application to the page’s Job (`view_yy`)  

Your help is much appreciated.

---

<div class="post-metadata">

**Author:** ![StephenChapman](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/stephenchapman/32/1759_2.png) [@StephenChapman](https://forums.knack.com/u/StephenChapman)\
**Post date:** [May 22, 2024, 9:28pm UTC](https://forums.knack.com/t/follow-url-with-multiple-filters-applied/17239/5 "2024-05-22T21:28:38Z")

</div>

@Team, it looks like you’ve done everything correctly.  
A couple of things to check:

1. Can you right-click and copy to here one of the Roles links in your Jobs grid to see if it’s the correct output?  
It should look something like:

```auto
https://domain.knack.com/app#jobs/job-details/664bc24d30ab65002910e51g?view_101_vars=%7B%22field_167%22%3A%5B%22664bc1b7198efb0038f7d187%22%5D%7D

```

1. If you right-click the page and click **Inspect** (Chrome or Edge), and navigate to the **Console** tab in the Developer console, do you see any red error messages?  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/knack/original/2X/c/c34175a99ef5f87875240c6c8af8fd643606f612.png)  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/knack/original/2X/9/9886eeff0dbb1d95d9e6314330aed1e9bcb165c0.png)

---

<div class="post-metadata">

**Author:** ![Team](https://avatars.discourse-cdn.com/v4/letter/t/b5a626/32.png) [@Team](https://forums.knack.com/u/Team)\
**Post date:** [May 23, 2024, 9:16am UTC](https://forums.knack.com/t/follow-url-with-multiple-filters-applied/17239/6 "2024-05-23T09:16:59Z")

</div>

Hi @StephenChapman ,

1. If i right click on the job in the grid, and copy the Link Address, I get the following: `https://staffit.knack.com/staffit#agency-login/job-details6/664661581118f5002743b87f` Which does not seem right.

2. No errors to see
