Reputation: 336
I'm trying to create a relationship between two modules, Accounts and another custom module that I called it "Estadisticos" and the final module name for SuiteCRM is "Mk902_Estadisticos". I've inserted data fine in the module via REST API but now I'm trying to create a relationship between these records with Accounts module, and the code I'm using is the same that i've used to succesfully between another modules as contacts with accounts, but in this case is not woprking for me sending me back this:
{"created":0,"failed":1,"deleted":0}
This is the code that works fine for default modules but not for custom modules
Map<String, Object> tmpHash = new LinkedHashMap<String, Object>();
List<String> tmpRelatedIds = new ArrayList<String>();
tmpRelatedIds.add(aRelatedId);
tmpHash.put("session", this.getSessionId());
tmpHash.put("module_name", METHOD_NAME);
tmpHash.put("module_id", anId);
tmpHash.put("link_field_name", aMethodRelated.toLowerCase());
tmpHash.put("related_ids", tmpRelatedIds);
JSONObject tmpRetreivedData = this.callWS("set_relationship", tmpHash);
if(tmpRetreivedData != null && tmpRetreivedData.size() > 0){
System.out.println(tmpRetreivedData.toJSONString());
return tmpRetreivedData;
}
else{
return null;
}
Maybe I can't create relationships via REST using a custom module?
NOTE: I'm coding in JAVA but PHP help could be useful too
Thanks a lot!
Upvotes: 1
Views: 1673
Reputation: 336
I've found the problem, for custom modules, the WebService was expecting the module related with this added "_accounts" for example if we was relating to Accounts
For example if your relate Contacts with Accounts, 'module_name' should be 'Accounts' the 'link_field_name' should be 'contacts', but If you have a custom module, for example 'Custom' and you are setting a relationship with Accounts, should be this: 'module_name' 'Accounts' 'link_field_name' 'custom_accounts'
Upvotes: 2