or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

attachments-files.mdauthentication.mdbulk-operations.mdfields-metadata.mdindex.mdinitialization.mdorganization-settings.mdrecords.mdrelated-records.mdtags-organization.mdusers.md

related-records.mddocs/

0

# Related Records

1

2

The Related Records module manages relationships between CRM records, including parent-child relationships, lookups, and many-to-many associations through related lists.

3

4

## Capabilities

5

6

### Related Records Operations

7

8

Comprehensive operations for managing record relationships and associations.

9

10

```javascript { .api }

11

/**

12

* Operations for managing relationships between CRM records

13

*/

14

class RelatedRecordsOperations {

15

/**

16

* Get related records for a specific record

17

* @param relatedListAPIName - API name of the related list

18

* @param recordId - ID of the parent record

19

* @param moduleAPIName - API name of the parent module

20

* @param paramInstance - Optional parameters for filtering and pagination

21

* @param headerInstance - Optional headers for request customization

22

* @returns Promise with APIResponse containing related records

23

*/

24

getRelatedRecords(relatedListAPIName: string, recordId: BigInt, moduleAPIName: string, paramInstance?: ParameterMap, headerInstance?: HeaderMap): Promise<APIResponse>;

25

26

/**

27

* Update multiple related records

28

* @param relatedListAPIName - API name of the related list

29

* @param recordId - ID of the parent record

30

* @param moduleAPIName - API name of the parent module

31

* @param request - Body wrapper containing updated record data

32

* @returns Promise with APIResponse containing update results

33

*/

34

updateRelatedRecords(relatedListAPIName: string, recordId: BigInt, moduleAPIName: string, request: BodyWrapper): Promise<APIResponse>;

35

36

/**

37

* Remove the relationship between records (delink)

38

* @param relatedListAPIName - API name of the related list

39

* @param recordId - ID of the parent record

40

* @param moduleAPIName - API name of the parent module

41

* @param paramInstance - Parameters specifying records to delink

42

* @returns Promise with APIResponse containing delink results

43

*/

44

delinkRecords(relatedListAPIName: string, recordId: BigInt, moduleAPIName: string, paramInstance: ParameterMap): Promise<APIResponse>;

45

46

/**

47

* Get a specific related record

48

* @param relatedListAPIName - API name of the related list

49

* @param recordId - ID of the parent record

50

* @param relatedRecordId - ID of the related record

51

* @param moduleAPIName - API name of the parent module

52

* @param paramInstance - Optional parameters for field selection

53

* @param headerInstance - Optional headers for request customization

54

* @returns Promise with APIResponse containing related record data

55

*/

56

getRelatedRecord(relatedListAPIName: string, recordId: BigInt, relatedRecordId: BigInt, moduleAPIName: string, paramInstance?: ParameterMap, headerInstance?: HeaderMap): Promise<APIResponse>;

57

58

/**

59

* Update a specific related record

60

* @param relatedListAPIName - API name of the related list

61

* @param recordId - ID of the parent record

62

* @param relatedRecordId - ID of the related record

63

* @param moduleAPIName - API name of the parent module

64

* @param request - Body wrapper containing updated record data

65

* @returns Promise with APIResponse containing update results

66

*/

67

updateRelatedRecord(relatedListAPIName: string, recordId: BigInt, relatedRecordId: BigInt, moduleAPIName: string, request: BodyWrapper): Promise<APIResponse>;

68

69

/**

70

* Remove relationship for a specific related record

71

* @param relatedListAPIName - API name of the related list

72

* @param recordId - ID of the parent record

73

* @param relatedRecordId - ID of the related record

74

* @param moduleAPIName - API name of the parent module

75

* @returns Promise with APIResponse containing delink results

76

*/

77

delinkRecord(relatedListAPIName: string, recordId: BigInt, relatedRecordId: BigInt, moduleAPIName: string): Promise<APIResponse>;

78

}

79

```

80

81

**Related Records Example:**

82

83

```javascript

84

const { RelatedRecordsOperations } = require("@zohocrm/nodejs-sdk-2.0/core/com/zoho/crm/api/related_records/related_records_operations");

85

const { BodyWrapper } = require("@zohocrm/nodejs-sdk-2.0/core/com/zoho/crm/api/related_records/body_wrapper");

86

const { Record } = require("@zohocrm/nodejs-sdk-2.0/core/com/zoho/crm/api/record/record");

87

const { ParameterMap } = require("@zohocrm/nodejs-sdk-2.0/routes/parameter_map");

88

89

const relatedRecordsOp = new RelatedRecordsOperations();

90

91

// Get contacts related to an account

92

const accountId = "123456789012345678";

93

const contactsResponse = await relatedRecordsOp.getRelatedRecords("Contacts", accountId, "Accounts");

94

95

if (contactsResponse != null) {

96

const responseObject = contactsResponse.object;

97

if (responseObject instanceof ResponseWrapper) {

98

const relatedRecords = responseObject.getData();

99

relatedRecords.forEach(contact => {

100

console.log(`Contact: ${contact.getFieldValue("Full_Name")}`);

101

});

102

}

103

}

104

105

// Update a related contact

106

const contactRecord = new Record();

107

contactRecord.setId("contact_id_here");

108

contactRecord.addFieldValue("Phone", "+1-555-0123");

109

110

const updateWrapper = new BodyWrapper();

111

updateWrapper.setData([contactRecord]);

112

113

const updateResponse = await relatedRecordsOp.updateRelatedRecord(

114

"Contacts",

115

accountId,

116

"contact_id_here",

117

"Accounts",

118

updateWrapper

119

);

120

121

// Delink a contact from an account

122

const delinkResponse = await relatedRecordsOp.delinkRecord(

123

"Contacts",

124

accountId,

125

"contact_id_here",

126

"Accounts"

127

);

128

```

129

130

### Related Lists Operations

131

132

Access related list metadata and configuration.

133

134

```javascript { .api }

135

/**

136

* Operations for accessing related list metadata

137

*/

138

class RelatedListsOperations {

139

/**

140

* Get all related lists for a module

141

* @param moduleAPIName - API name of the parent module

142

* @returns Promise with APIResponse containing related lists metadata

143

*/

144

getRelatedLists(moduleAPIName: string): Promise<APIResponse>;

145

146

/**

147

* Get details of a specific related list

148

* @param relatedListId - ID of the related list

149

* @param moduleAPIName - API name of the parent module

150

* @returns Promise with APIResponse containing related list details

151

*/

152

getRelatedList(relatedListId: string, moduleAPIName: string): Promise<APIResponse>;

153

}

154

```

155

156

**Related Lists Example:**

157

158

```javascript

159

const { RelatedListsOperations } = require("@zohocrm/nodejs-sdk-2.0/core/com/zoho/crm/api/related_lists/related_lists_operations");

160

161

const relatedListsOp = new RelatedListsOperations();

162

163

// Get all related lists for Accounts module

164

const relatedListsResponse = await relatedListsOp.getRelatedLists("Accounts");

165

166

if (relatedListsResponse != null) {

167

const responseObject = relatedListsResponse.object;

168

if (responseObject instanceof ResponseWrapper) {

169

const relatedLists = responseObject.getRelatedLists();

170

relatedLists.forEach(relatedList => {

171

console.log(`Related List: ${relatedList.getDisplayLabel()}, API Name: ${relatedList.getAPIName()}`);

172

});

173

}

174

}

175

```

176

177

### Related Records Data Model

178

179

Core data model for related record operations.

180

181

```javascript { .api }

182

/**

183

* Body wrapper for related records requests

184

*/

185

class BodyWrapper {

186

/** Get related records data */

187

getData(): Record[];

188

/** Set related records data */

189

setData(data: Record[]): void;

190

191

/** Get workflow trigger settings */

192

getWfTrigger(): boolean[];

193

/** Set workflow trigger settings */

194

setWfTrigger(wfTrigger: boolean[]): void;

195

}

196

197

/**

198

* Response wrapper for related records GET operations

199

*/

200

class ResponseWrapper {

201

/** Get related records data */

202

getData(): Record[];

203

/** Get pagination info */

204

getInfo(): Info;

205

}

206

207

/**

208

* Action wrapper for related records POST/PUT/DELETE operations

209

*/

210

class ActionWrapper {

211

/** Get action results */

212

getData(): ActionResponse[];

213

}

214

```

215

216

### Related Lists Data Model

217

218

Data model for related list metadata.

219

220

```javascript { .api }

221

/**

222

* Represents a related list configuration

223

*/

224

class RelatedList {

225

/** Get related list ID */

226

getId(): string;

227

/** Set related list ID */

228

setId(id: string): void;

229

230

/** Get sequence number */

231

getSequenceNumber(): number;

232

/** Set sequence number */

233

setSequenceNumber(sequenceNumber: number): void;

234

235

/** Get display label */

236

getDisplayLabel(): string;

237

/** Set display label */

238

setDisplayLabel(displayLabel: string): void;

239

240

/** Get API name */

241

getAPIName(): string;

242

/** Set API name */

243

setAPIName(apiName: string): void;

244

245

/** Get related list module */

246

getModule(): string;

247

/** Set related list module */

248

setModule(module: string): void;

249

250

/** Get related list name */

251

getName(): string;

252

/** Set related list name */

253

setName(name: string): void;

254

255

/** Get related list action */

256

getAction(): string;

257

/** Set related list action */

258

setAction(action: string): void;

259

260

/** Get href for API access */

261

getHref(): string;

262

/** Set href for API access */

263

setHref(href: string): void;

264

265

/** Get related list type */

266

getType(): string;

267

/** Set related list type */

268

setType(type: string): void;

269

270

/** Get connected module */

271

getConnectedModule(): string;

272

/** Set connected module */

273

setConnectedModule(connectedModule: string): void;

274

275

/** Get linking module */

276

getLinkingModule(): string;

277

/** Set linking module */

278

setLinkingModule(linkingModule: string): void;

279

}

280

281

/**

282

* Response wrapper for related lists operations

283

*/

284

class ResponseWrapper {

285

/** Get related lists data */

286

getRelatedLists(): RelatedList[];

287

}

288

```

289

290

### Query Parameters

291

292

Parameters for customizing related record operations.

293

294

```javascript { .api }

295

/**

296

* Parameters for getRelatedRecords operation

297

*/

298

class GetRelatedRecordsParam {

299

static PAGE: Param; // Page number for pagination

300

static PER_PAGE: Param; // Records per page

301

static FIELDS: Param; // Fields to retrieve

302

static IDS: Param; // Specific record IDs

303

static SORT_BY: Param; // Sort field

304

static SORT_ORDER: Param; // Sort order (asc/desc)

305

}

306

307

/**

308

* Headers for getRelatedRecords operation

309

*/

310

class GetRelatedRecordsHeader {

311

static IF_MODIFIED_SINCE: Header; // Get records modified since date

312

static X_EXTERNAL: Header; // External system identifier

313

}

314

315

/**

316

* Parameters for getRelatedRecord operation

317

*/

318

class GetRelatedRecordParam {

319

static FIELDS: Param; // Fields to retrieve

320

}

321

322

/**

323

* Headers for getRelatedRecord operation

324

*/

325

class GetRelatedRecordHeader {

326

static IF_MODIFIED_SINCE: Header; // Get record if modified since date

327

static X_EXTERNAL: Header; // External system identifier

328

}

329

330

/**

331

* Parameters for updateRelatedRecords operation

332

*/

333

class UpdateRelatedRecordsParam {

334

static IDS: Param; // Record IDs to update

335

}

336

337

/**

338

* Parameters for delinkRecords operation

339

*/

340

class DelinkRecordsParam {

341

static IDS: Param; // Record IDs to delink

342

}

343

```

344

345

**Parameter Usage Example:**

346

347

```javascript

348

const { ParameterMap } = require("@zohocrm/nodejs-sdk-2.0/routes/parameter_map");

349

const { HeaderMap } = require("@zohocrm/nodejs-sdk-2.0/routes/header_map");

350

const { GetRelatedRecordsParam, GetRelatedRecordsHeader } = require("@zohocrm/nodejs-sdk-2.0/core/com/zoho/crm/api/related_records/related_records_operations");

351

352

// Setup parameters for getting related records

353

const paramMap = new ParameterMap();

354

await paramMap.add(GetRelatedRecordsParam.FIELDS, "Full_Name,Email,Phone,Title");

355

await paramMap.add(GetRelatedRecordsParam.PAGE, 1);

356

await paramMap.add(GetRelatedRecordsParam.PER_PAGE, 200);

357

await paramMap.add(GetRelatedRecordsParam.SORT_BY, "Full_Name");

358

await paramMap.add(GetRelatedRecordsParam.SORT_ORDER, "asc");

359

360

// Setup headers

361

const headerMap = new HeaderMap();

362

await headerMap.add(GetRelatedRecordsHeader.IF_MODIFIED_SINCE, new Date("2023-01-01T00:00:00Z"));

363

364

// Get related records with filters

365

const response = await relatedRecordsOp.getRelatedRecords(

366

"Contacts",

367

"account_id_here",

368

"Accounts",

369

paramMap,

370

headerMap

371

);

372

```

373

374

### Common Related Lists

375

376

Standard related lists available across CRM modules.

377

378

```javascript { .api }

379

/**

380

* Common related list API names

381

*/

382

class CommonRelatedLists {

383

// Account related lists

384

static ACCOUNT_CONTACTS: string = "Contacts";

385

static ACCOUNT_DEALS: string = "Deals";

386

static ACCOUNT_CASES: string = "Cases";

387

static ACCOUNT_ACTIVITIES: string = "Activities";

388

static ACCOUNT_NOTES: string = "Notes";

389

static ACCOUNT_ATTACHMENTS: string = "Attachments";

390

391

// Contact related lists

392

static CONTACT_DEALS: string = "Deals";

393

static CONTACT_CASES: string = "Cases";

394

static CONTACT_ACTIVITIES: string = "Activities";

395

static CONTACT_NOTES: string = "Notes";

396

static CONTACT_ATTACHMENTS: string = "Attachments";

397

398

// Deal related lists

399

static DEAL_CONTACT_ROLES: string = "Contact_Roles";

400

static DEAL_STAGE_HISTORY: string = "Stage_History";

401

static DEAL_ACTIVITIES: string = "Activities";

402

static DEAL_NOTES: string = "Notes";

403

static DEAL_ATTACHMENTS: string = "Attachments";

404

405

// Lead related lists

406

static LEAD_ACTIVITIES: string = "Activities";

407

static LEAD_NOTES: string = "Notes";

408

static LEAD_ATTACHMENTS: string = "Attachments";

409

}

410

```

411

412

### Relationship Types

413

414

Different types of relationships between records.

415

416

```javascript { .api }

417

/**

418

* Types of record relationships

419

*/

420

class RelationshipType {

421

static ONE_TO_MANY: string = "one_to_many"; // Parent-child relationship

422

static MANY_TO_MANY: string = "many_to_many"; // Junction table relationship

423

static LOOKUP: string = "lookup"; // Lookup field relationship

424

static MASTER_DETAIL: string = "master_detail"; // Master-detail relationship

425

}

426

```