Workflow adds unwanted relationship if multiple relations #5141

Open
opened 2026-02-20 16:30:20 -05:00 by deekerman · 0 comments
Owner

Originally created by @gunnicom on GitHub (Jan 10, 2024).

Preconditions:
Module A
Module B
2 relations 1 to many from module A to module B ( module A got the fields, module B got the subpanels:
modA_modb_c
modA_modB_1_c

Relate object in Module A to Onject in Module B only on the first relationship modA_modb_c.
modA_modB_1_c stays empty.

Add a Workflow, on_save:
If condition in module A is met, change something in Module B

Open Object in EditView (not Inline Edit), and save with condition met.
Workflow will run, change what is to change in Module B,
BUT additionally it adds Module B as related in modA_modB_1_c

Does not happen in Inline Edit. Reasons explained in "What happened?"

What happened?

Saving module A sends following:
$REQUEST['relate_to']="ModuleA"
$
REQUEST['relate_id']="THEID"

The workflow runs ->save() (around 410 actionCreateRecord)
save runs save_relationship_changes (around 2369 SugarBean)
set_relationship_info() gets called
set_relationship_info gets beans to relate to from above $_REQUEST
So setting relation to the wrong relationship.

Expected Behavior

Workflow does not add the additional relationship

Actual Behavior

See above "What happens".

Possible Fix

Set not_use_rel_in_req to true before save in workflow, so REQUEST variables wont be used to create a relationship.

Steps to Reproduce

See on Top

Your Environment

  • SuiteCRM Version used: 7.14.2
  • Browser name and version (e.g. Chrome Version 51.0.2704.63 (64-bit)):
  • Environment name and version (e.g. MySQL, PHP 7):
  • Operating System and version (e.g Ubuntu 16.04):
Originally created by @gunnicom on GitHub (Jan 10, 2024). Preconditions: Module A Module B 2 relations 1 to many from module A to module B ( module A got the fields, module B got the subpanels: modA_modb_c modA_modB_1_c Relate object in Module A to Onject in Module B only on the first relationship modA_modb_c. modA_modB_1_c stays empty. Add a Workflow, on_save: If condition in module A is met, change something in Module B Open Object in EditView (not Inline Edit), and save with condition met. Workflow will run, change what is to change in Module B, BUT additionally it adds Module B as related in modA_modB_1_c Does not happen in Inline Edit. Reasons explained in "What happened?" #### What happened? Saving module A sends following: $_REQUEST['relate_to']="ModuleA" $_ REQUEST['relate_id']="THEID" The workflow runs ->save() (around 410 actionCreateRecord) save runs save_relationship_changes (around 2369 SugarBean) set_relationship_info() gets called set_relationship_info gets beans to relate to from above $_REQUEST So setting relation to the wrong relationship. #### Expected Behavior Workflow does not add the additional relationship #### Actual Behavior See above "What happens". #### Possible Fix Set not_use_rel_in_req to true before save in workflow, so REQUEST variables wont be used to create a relationship. #### Steps to Reproduce See on Top #### Your Environment <!--- Include as many relevant details about the environment you experienced the bug in --> * SuiteCRM Version used: 7.14.2 * Browser name and version (e.g. Chrome Version 51.0.2704.63 (64-bit)): * Environment name and version (e.g. MySQL, PHP 7): * Operating System and version (e.g Ubuntu 16.04):
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/SuiteCRM-SuiteCRM#5141
No description provided.