Skip to Content Skip to Menu

🌟 CB Editor Assistant 1.0.0 is here! Discover our new AI Joomla Plugin that wrote its story! (and this banner!)
Start at just $12.50/month* or 💸 save 30% with our 🛍️ Black Friday Intro Offer for your subscription's lifetime
🎉 Black Friday sale is here! Great savings on professional and developer memberships! Get 25% off now with code BLACK-FRIDAY-2024!

How to delete a value from a multi-value field by Auto Action type Query

  • MMDoege
  • MMDoege
  • OFFLINE
  • Posts: 98
  • Thanks: 3
  • Karma: 0
5 years 9 months ago #310206 by MMDoege
I'm afraid I haven't found a clue in the forum.

For data consistency we have to delete values from a ("parent-") field when a user discards specific values from a ("child-") field.
The parent-field is actually of type Query Drop Down (Multi-select).

I wonder if someone has done the same and would like to share how to manipulate the parent field's value string.

An Auto Action type Query will have to trigger an "UPDATE jos_comprofiler SET cb_parent_field = 'updated string';" SQL command.
My question actually is how to delete the correct value as it may by positioned at beginning or end of the value string or somewhere else.

Sample: User triggers Auto Action because of deleting or deselecting a value somewhere. This has to delete "Detection" from multi-value field.

Before:
Automation|*|Detection|*|Inspection|*|Mapping ...

After
Automation|*|Inspection|*|Mapping ...

Would heartly appreciate ready-to-go code/string functions ... any suggestions?

Thank you.

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48560
  • Thanks: 8292
  • Karma: 1445
5 years 9 months ago #310217 by krileon
Not understanding your usecase. So you've 2 fields which both have Detection? If in the second field Detection is no longer selected you need to also deselect it from the first field?


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • MMDoege
  • MMDoege
  • OFFLINE
  • Posts: 98
  • Thanks: 3
  • Karma: 0
5 years 9 months ago #310221 by MMDoege
Thank you for your quick reply.

Well, almost about that. Screenshot attached demonstrates the issue.

In this profile a user selects the company's applications areas they offer ("parent-field").
In addition user can proceed and select specific expertises his company has in some of applications areas selected ("child-fields and "sub-child-fields").

When it comes to deletions then this will become somewhat complex because some values will not be shown in profile because their "parent-field" is empty, but they are still in the DB and an search will return wrong results.

Example (see screenshot):

When user deletes "Inspection" in field "Application Areas" values "Infrastructure" and "Roofs" will conditionally not appear in his profile but they are still in DB. From a content perspective this is false as the company does not offer expertises in roof inspections any longer.
And vice versa, when deleting "child" and "sub-children" this can lead to housekeeping in "parent-field(s)" to keep DB correct.

In general deletion is not an issue because awesome Auto Action Plug will do the job perfectly as I have implemented it for single-value fields already.

My problem is to delete values from a multi-value field in this context.

Thanks.
Attachments:

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48560
  • Thanks: 8292
  • Karma: 1445
5 years 9 months ago - 5 years 9 months ago #310223 by krileon
Ok, you should be able to use a Field action for that. Next enable Format Functions under Parameters. You'll then need to use the Replace format function using a pattern, which is basically a PHP preg_replace.

Code:
[cb:parse function="replace" search="/\|\*\|Logistics|Logistics\|\*\||Logistics/i" replace=""][cb_expertise][/cb:parse]

That should ideally replace Logistics in a multiselect. Note if you've 2 values containing Logistics you will run into issues with this so each value should be pretty unique ideally. More details on format functions can be found at the bottom of the Parameters tab.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
Last edit: 5 years 9 months ago by krileon.
The following user(s) said Thank You: MMDoege

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum