Adding data using Rules and the "After saving a new commerce license" event

Created on 22 February 2017, over 8 years ago
Updated 19 August 2025, 5 days ago

I have a rule that sets field values on the user form with data from the license's product when a new license is created. If the user already has a license connected to the same product type before the rule is triggered (i.e. I'm adding a second license to the user), the field data is set correctly. However, if the user does not already have a license with the same product type (i.e. I'm creating their first license or I'm adding a license that is connected to a different product type), the rule fires but the data is not set.

Here's my rule:

{ "rules_on_license_creation_set_extra_user_roles" : {
"LABEL" : "On license creation, set extra user roles",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"TAGS" : [ "Commerce License" ],
"REQUIRES" : [ "rules", "commerce_license" ],
"ON" : { "commerce_license_insert" : [] },
"IF" : [
{ "entity_has_field" : {
"entity" : [ "commerce-license:product" ],
"field" : "field_subscriber_type"
}
},
{ "entity_has_field" : {
"entity" : [ "commerce-license:owner" ],
"field" : "field_subscriber_type"
}
},
{ "data_is" : { "data" : [ "commerce-license:type" ], "value" : "role" } }
],
"DO" : [
{ "data_set" : {
"data" : [ "commerce-license:owner:field-subscriber-type" ],
"value" : [ "commerce-license:product:field-subscriber-type" ]
}
},
{ "user_remove_role" : {
"account" : [ "commerce-license:owner" ],
"roles" : { "value" : { "9" : "9", "11" : "11", "36" : "36" } }
}
}
]
}
}

I've done similar rules when saving new nodes or new users and I haven't had this problem, so I'm assuming it's something to do with the license. But maybe it's an issue with rules? Any tips would be appreciated.

πŸ’¬ Support request
Status

Closed: outdated

Version

1.3

Component

User interface

Created by

πŸ‡ΊπŸ‡ΈUnited States BYUStudies

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024