SugarCRM Rest API - set_relationship for custom relationships

Hey There,

I am trying to write a client working with the Rest API to work with Sugar/SuiteCRM, which involves creating new links between modules. I have created a module with the module builder, which has a custom many-to-many relationship between itself and the “Cases” module. In order to add a relationship entry to the DB, I am using the set_relationship method, but I can’t seem to get it to work correctly, and it always returns as failed.

I have tried various configurations for the arguments I am using, but I have a few questions:

[ol]
[li]Does the order matter? - ie: are the module_name and link_field_name arguments interchangeable as long as the ids correspond?
[/li]
[li] Is the link_field_name supposed to be the name of the relating module, the name of the relationship in the studio, or the name of the database table for the links? … or something else I am not aware of?
[/li]
[li] Is there any way to see a more descriptive error message based on the failed request so I can debug better?
[/ol]

Thank you!

Pat

No. i think it does not matter anymore

1 Like

https://developer.sugarcrm.com/2011/12/08/howto-dealing-with-set_relationship-failures/

The fourth parameter must be the name of link field in the module’s vardefs, not the name of the target module or the relationship. This tends to be the most confusing part for people, as finding this out requires you to dig into the module’s vardefs.php file for more details, as you need to find a field of type ‘link’ that the ‘relationship’ field matching the name of the relationship between the modules. You can find the relationship name in Studio by looking at the ‘Relationships’ screen in Studio for the module.