Bug 40651

Summary: Item search custom field selection is not populated in shareable link
Product: Koha Reporter: Nick Clemens (kidclamp) <nick>
Component: Staff interfaceAssignee: Nick Clemens (kidclamp) <nick>
Status: Pushed to main --- QA Contact: Brendan Lawlor <blawlor>
Severity: normal    
Priority: P5 - low CC: blawlor, gmcharlt, karie.straube, lisette
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=39072
GIT URL: Change sponsored?: ---
Patch complexity: Small patch Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
25.11.00
Circulation function:
Bug Depends on: 14322    
Bug Blocks:    
Attachments: Bug 40651: Select custom search field if passed in via link
Bug 40651: Add a link to manage item search fields
Bug 40651: Select custom search field if passed in via link
Bug 40651: Add a link to manage item search fields
Bug 40651: Select custom search field if passed in via link
Bug 40651: Add a link to manage item search fields

Description Nick Clemens (kidclamp) 2025-08-14 12:59:10 UTC
To recreate:
1 - Browse to Administration - Item search fields
2 - Add a new search field pointing to a marc field with some known value on a record with items
3 - Browse to Item search
4 - Construct a search using your new field and search
5 - From results click 'Copy shareable link'
6 - Go to the link
7 - No results or wrong results!
8 - Edit the search
9 - Note your custom field is not selected
Comment 1 Nick Clemens (kidclamp) 2025-08-14 13:05:57 UTC
Created attachment 185391 [details] [review]
Bug 40651: Select custom search field if passed in via link

This patch checks for a custom field value and preselects it in the dropdown if present

To test:
1 - Browse to Administration - Item search fields
2 - Add a new search field pointing to a marc field with some known value on a record with items
3 - Browse to Item search
4 - Construct a search using your new field and search
5 - From results click 'Copy shareable link'
6 - Go to the link
7 - No results or wrong results!
8 - Edit the search
9 - Note your custom field is not selected
10 - Apply patch
11 - Visit the link again
12 - Correct results!
13 - Edit search
14 - Custom field is correctly selected!
Comment 2 Nick Clemens (kidclamp) 2025-08-14 13:05:59 UTC
Created attachment 185392 [details] [review]
Bug 40651: Add a link to manage item search fields

When debugging this reported issue, I didn't know where to add these fields, let's make it more
obvious for users who can manage those

To test:
1 - Be a user who can manage item search fields
    i.e. have manage_item_search_fields permission
2 - Go to item search
3 - Note a link to Manage item search fields
4 - Confirm it works
5 - Be a user without the permission
6 - Go to item search
7 - There is no link!
Comment 3 Owen Leonard 2025-08-14 15:42:44 UTC
Created attachment 185400 [details] [review]
Bug 40651: Select custom search field if passed in via link

This patch checks for a custom field value and preselects it in the
dropdown if present

To test:
1 - Browse to Administration - Item search fields
2 - Add a new search field pointing to a marc field with some known
    value on a record with items
3 - Browse to Item search
4 - Construct a search using your new field and search
5 - From results click 'Copy shareable link'
6 - Go to the link
7 - No results or wrong results!
8 - Edit the search
9 - Note your custom field is not selected
10 - Apply patch
11 - Visit the link again
12 - Correct results!
13 - Edit search
14 - Custom field is correctly selected!

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 4 Owen Leonard 2025-08-14 15:42:46 UTC
Created attachment 185401 [details] [review]
Bug 40651: Add a link to manage item search fields

When debugging this reported issue, I didn't know where to add these
fields, let's make it more obvious for users who can manage those

To test:
1 - Be a user who can manage item search fields
    i.e. have manage_item_search_fields permission
2 - Go to item search
3 - Note a link to Manage item search fields
4 - Confirm it works
5 - Be a user without the permission
6 - Go to item search
7 - There is no link!

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Comment 5 Brendan Lawlor 2025-08-20 15:52:03 UTC
Created attachment 185591 [details] [review]
Bug 40651: Select custom search field if passed in via link

This patch checks for a custom field value and preselects it in the
dropdown if present

To test:
1 - Browse to Administration - Item search fields
2 - Add a new search field pointing to a marc field with some known
    value on a record with items
3 - Browse to Item search
4 - Construct a search using your new field and search
5 - From results click 'Copy shareable link'
6 - Go to the link
7 - No results or wrong results!
8 - Edit the search
9 - Note your custom field is not selected
10 - Apply patch
11 - Visit the link again
12 - Correct results!
13 - Edit search
14 - Custom field is correctly selected!

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>




 Depends: bug xxxx 14322
Comment 6 Brendan Lawlor 2025-08-20 15:52:06 UTC
Created attachment 185592 [details] [review]
Bug 40651: Add a link to manage item search fields

When debugging this reported issue, I didn't know where to add these
fields, let's make it more obvious for users who can manage those

To test:
1 - Be a user who can manage item search fields
    i.e. have manage_item_search_fields permission
2 - Go to item search
3 - Note a link to Manage item search fields
4 - Confirm it works
5 - Be a user without the permission
6 - Go to item search
7 - There is no link!

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Brendan Lawlor <blawlor@clamsnet.org>
Comment 7 Brendan Lawlor 2025-08-20 16:00:23 UTC
This makes sense that we need to select the custom field options that are passed in the shareable link. That was not included in bug 14322 originally so I'm really happy to see this fix. 

The link to manage custom fields is also a nice addition for admins.

Thanks everyone! Passing QA.
Comment 8 Lucas Gass (lukeg) 2025-08-20 18:57:45 UTC
Nice work everyone!

Pushed to main for 25.11