How do we find out the unique fieldname in sugar crm?

Hi there ,

 I have two queries on Sugar CRM meta.

I used Rest api to get the fields from sugar

GET /rest/metadata?type_filter=modules,relationships&module_filter=Calls.

Response :

{"modules":
{"Calls":
{"fields":
{"leads": {
"name": "leads",
"type": "link",
"relationship": "calls_leads",
"source": "non-db",
"vname": "LBL_LEADS"
},
"lead_id": {
"name": "lead_id",
"type": "relate",
"rname": "id",
"vname": "LBL_LEAD_ID",
"link": "leads",
"source": "non-db",
"studio": false
},
"lead_name": {
"name": "lead_name",
"rname": "name",
"db_concat_fields": [
  "first_name",
  "last_name"
],
"id_name": "lead_id",
"massupdate": false,
"vname": "LBL_LEAD_NAME",
"type": "relate",
"link": "leads",
"table": "leads",
"isnull": "true",
"module": "Leads",
"join_name": "leads",
"dbType": "varchar",
"source": "non-db",
"importable": "false",
"studio": false
},

Queries : 

1. Which field - name/id_name is unique for all fields? 

2.  all the relate type fields have module ? i got the response which has lead_id without module ? 

  • I am trying to integrate sugar crm using Rest API. Getting fields from sugar and display it to our product . while getting fields , want to know field behavior. 

  • Lets talk about relate fields on SugarCRM:

    <field>_name : indicates the name of related record. This field has as attributes the module and 'link'. The attribute 'link' points to another field which means "a list of related records" and it points to a real relationship.

    <field>_id : indicates the foreign key, that means, this is the field to be populated

    The integrated application needs to cary about the id_name field.

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • Hello,

    You are correctly retrieving the data field placeholder structure through the metadata api. That's already a great step, as that gives you the schema/structure for the module you are looking at, for all data types that are stored into the system.

    If you need only the information provided by the "lookup" fields for one-to-many relationships, you read the field, and you are good (normally name field or first_name and last_name fields of the other module).

    What I believe you are asking for is, how do I deal (read/write) with relationships in Sugar?

    The following approach really applies for both relate and actual one-to-many relationships fields, and also for many-to-many or many-to-one relationships.

    As you need to retrieve more information from related records, you would have to do something more involved:

    * find the "link field" (which refers to the correct relationship in Sugar with the other module) - To do so you find the field with type='link' on the metadata api you referred to, for the specific module

    * if you are not sure you are looking at the correct link field, potentially you can and should cross check that the link field's relationship (in your case "calls_leads") refers to the correct relationship that you want to retrieve/save (/rest/v11_8/metadata?type_filter=relationships). This step will tell you what type of relationship it is and how the actual records are related together

    * leverage the relationship apis to retrieve/add/delete relationships of other records to the current one (one of the get relationship api link to the docs is here)

    Hopefully it helps you get started integrating with sugar when dealing with relationships

    --

    Enrico Simonetti

    Sugar veteran (from 2007)

    www.naonis.tech


    Feel free to reach out for consulting regarding:

    • API Integration and Automation Services
    • Sugar Architecture
    • Sugar Performance Optimisation
    • Sugar Consulting, Best Practices and Technical Training
    • AWS and Sugar Technical Help
    • CTO-as-a-service
    • Solutions-as-a-service
    • and more!

    All active SugarCRM certifications

    Actively working remotely with customers based in APAC and in the United States