Problem/Motivation
I try to create a simple log in each content when user save a content. I can use "Set Data Value" to set data into the multivalue text field but that will only set data value to first text field. Same configuration but change to "Add list item", I got error :
TypeError: Argument 1 passed to Drupal\rules\Plugin\RulesAction\DataListItemAdd::doExecute() must be of the type array, object given in Drupal\rules\Plugin\RulesAction\DataListItemAdd->doExecute() (line 58 of /web/modules/contrib/rules/src/Plugin/RulesAction/DataListItemAdd.php)
Steps to reproduce
uuid: 95a0fca4-347e-42d3-94ff-d4e705f9998d
langcode: en
status: true
dependencies: { }
id: info_logs_update
label: 'Info - Logs Update'
events:
-
event_name: 'rules_entity_presave:node'
description: ''
tags: { }
config_version: '3'
expression:
id: rules_rule
uuid: b0ec0810-fe61-4eb3-b81b-f13daa3c3c14
weight: 0
conditions:
id: rules_and
uuid: e1b97a14-8f1f-4db8-a2d3-62069905174f
weight: 0
conditions:
-
id: rules_condition
uuid: a51fa88c-7d66-476b-b3d5-d580fefaa426
weight: -50
context_values:
type: node
bundle: info_list
context_mapping:
entity: node
context_processors:
type:
rules_tokens: { }
bundle:
rules_tokens: { }
provides_mapping: { }
condition_id: rules_entity_is_of_bundle
negate: false
-
id: rules_condition
uuid: 11667c5d-2c02-4567-8406-e207c30fceab
weight: -48
context_values: { }
context_mapping:
data: node.field_info_logs
context_processors: { }
provides_mapping: { }
condition_id: rules_data_is_empty
negate: true
actions:
id: rules_action_set
uuid: 0afaeef4-6056-4293-a902-caff2050bdca
weight: 0
actions:
-
id: rules_action
uuid: ba3b93c6-057e-4b81-b33b-b6445d946197
weight: -50
context_values:
token: '[date:html_datetime]'
token_entity: ''
context_mapping: { }
context_processors:
token:
rules_tokens: { }
token_entity:
rules_tokens: { }
provides_mapping:
token_value: token_date_value
action_id: rules_token_get_token_value
-
id: rules_action
uuid: 063b2028-7097-4d39-ac25-f35a5fcb576b
weight: 0
context_values:
item: '{{token_date_value}}'
unique: ''
position: end
context_mapping:
list: node.field_info_logs
context_processors:
item:
rules_tokens: { }
unique:
rules_tokens: { }
position:
rules_tokens: { }
provides_mapping: { }
action_id: rules_list_item_add
Can anyone help me to solve this problem?
Thanks,
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Comments
Comment #2
tr commentedPlease provide more details.
Please describe what kind of field you're using and how it's configured. There are six standard types of text fields by default in Drupal.
Please provide a Rule that doesn't use actions from another contributed module. I don't want to have to install an additional module (which you didn't mention) in order to try to reproduce the problem, and if you can't reproduce the problem with just core Rules it's possible the problem is with that other module.
Also, Rules has a global context variable just like in D7 to give you the current date:
@rules.current_date_context:current_date. You can format it any way you like using data filters. For your use case it would be{{ @rules.current_date_context:current_date | format_date('html_datetime) }}Support for token module tokens is not needed when there is access to actual typed data, which it is in almost all cases.In general though I think the message is pretty clear even though it's not user friendly - you're trying to use a data type that's not allowed in that context, so in order to help you further we need to know the details of the field type etc. Also search google for that error message - this has been discussed many times. Until the UI is finished (and no one has worked on the list UI yet) you will have to self-check your data types to make sure you are setting the right values.
Comment #3
abx commentedI use "Text (plain, long)" field format with "Allowed number of values" set to "Unlimited".
Regarding token, I have removed it, replaced it any text in which I just need to enter my own text together with Date. (Date is removed for now)
I understand that the error is pretty clear that I gave "object" to the "array" (list) field but I have no idea how to change from "object" to "array" using rules. I have tried to use action "Convert data" but that didn't work with this kind of data.
Below is my updated config :