Setting data values in a paragraphs field with multiple values via rules?

Over the last few days I’ve been investigating and experimenting on how to use rules to alter fields within a paragraphs bundle on a node. The paragraph field on the node allows for multiple values(to a maximum of 6). In the paragraph bundle there is a radio button field where users select a “type” which then triggers the visibility of a corresponding field. The ‘Conditional Fields’ module has an option to ‘reset to default value’ when a dependency is not triggered, but this fails to work for me(needs a patch I believe). In place of that I am using rules to clean the form on submit. This worked perfectly with normal node fields, however it’s not so simple when the fields I need to clean are inside a paragraph entity and there are multiple instances of the entity within the field.

In my experimentation I was able to reset the first and only the first paragraph bundle isntance with a data selector that looks like this:


The problem here(I think) is that I’m selecting only the first ‘row’ in the paragraphs field thanks to the :0: in the data selector? I’m only guessing at the meaning of that number, the labeling of data selectors is cryptic to me.

Without that 0 or any of the other numbers(ex: 1,2,3) shown in the data selector options I can’t even access the appropriate field I want to alter.

Screenshot of available data selectors

I figured that the right direction is to loop through the paragraphs field and select each ‘row’ individually and then,via the current list item of the loop, select the appropriate field to alter it that way but so far have been completely unsuccessful.

I believe I need a component(of type rule) and a standard rule to do this, right?

The rule:

Condition = Entity has field – Parameter: Entity: [node], Field: field_paragraphs_categories
Loop = node:field-paragraphs-categories & add component as an action
Action = Fetch entity by id – current-paragraph:item-id

The component(type rule):

Condition = Data comparison – current-paragraph:item-id(from loop):field-service-type
Action = Set a data value – current-paragraph:item-id(from loop):field-select-service

I can’t seem to simply pass the id of the current item of the loop to the data comparison or action in the component so i can drill down to the fields it contains. This is where I’m getting stumped. Perhaps my entire method is wrong though, I don’t know.

The closest instruction I’ve been able to find is in this thread @ #9 but, while similar, offers no insight into the parts I’m having difficulty with.

The short version of this support request is: How do I loop through a paragraphs field with multiple values, set a data comparison condition on ‘service-type’, and then set a data value for ‘select-service’ if the condition evaluates to true.

Drupal version: