Skip to content

allow creating related records from SearchKit#35665

Merged
mattwire merged 1 commit into
civicrm:masterfrom
MegaphoneJon:create-sktask-entityid
May 19, 2026
Merged

allow creating related records from SearchKit#35665
mattwire merged 1 commit into
civicrm:masterfrom
MegaphoneJon:create-sktask-entityid

Conversation

@MegaphoneJon
Copy link
Copy Markdown
Contributor

Overview

I saw that 6.13+ supports creating SearchKit links that take action on a different entity. However, this fails if the API action you want to use is create.

Before

Can't use create in a searchKitTask hook.

After

Can.

Technical Details

Before this PR, it's assumed that any create action was on the same entity as the record being viewed. So the id isn't helpful because you can't pass an id to a created record. Additionally, the way that SearchKit passes the ID is in an array element named records - which save supports but create does not.

This PR takes advantage of the similarity between the create and save APIs - if you use create with an idField, it's converted to a save.

Comments

I considered just adding a note in the docs that create wasn't supported, just use save - which is what I'd have done if I valued my time more. But it seems arbitrary to support all API actions except one here.

@civibot
Copy link
Copy Markdown

civibot Bot commented May 13, 2026

🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷

Introduction for new contributors...
  • If this is your first PR, an admin will greenlight automated testing with the command ok to test or add to whitelist.
  • A series of tests will automatically run. You can see the results at the bottom of this page (if there are any problems, it will include a link to see what went wrong).
  • A demo site will be built where anyone can try out a version of CiviCRM that includes your changes.
  • If this process needs to be repeated, an admin will issue the command test this please to rerun tests and build a new demo site.
  • Before this PR can be merged, it needs to be reviewed. Please keep in mind that reviewers are volunteers, and their response time can vary from a few hours to a few weeks depending on their availability and their knowledge of this particular part of CiviCRM.
  • A great way to speed up this process is to "trade reviews" with someone - find an open PR that you feel able to review, and leave a comment like "I'm reviewing this now, could you please review mine?" (include a link to yours). You don't have to wait for a response to get started (and you don't have to stop at one!) the more you review, the faster this process goes for everyone 😄
  • To ensure that you are credited properly in the final release notes, please add yourself to contributor-key.yml
  • For more information about contributing, see CONTRIBUTING.md.
Quick links for reviewers...

➡️ Online demo of this PR 🔗

@civibot civibot Bot added the master label May 13, 2026
@MegaphoneJon
Copy link
Copy Markdown
Contributor Author

test this please

@colemanw
Copy link
Copy Markdown
Member

Thanks @MegaphoneJon this makes sense. Now that I think of it, I wonder why we aren't just always converting Create to Save here... might be that for some API entities there's a bigger difference btw the two.

Anyway this looks great!

@colemanw colemanw added the merge ready PR will be merged after a few days if there are no objections label May 14, 2026
@mattwire mattwire merged commit fd925fb into civicrm:master May 19, 2026
1 check passed
@MegaphoneJon MegaphoneJon deleted the create-sktask-entityid branch May 19, 2026 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

master merge ready PR will be merged after a few days if there are no objections

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants