Run your entire business on Zoho with our unified cloud software, designed to help you break down silos between departments and increase organizational efficiency.
class Layout
{
/**
* Get Layouts
* This method is used to get metadata about all the layouts of a module and print the response.
* @param {String} moduleAPIName The API Name of the module to get layouts.
*/
static async getLayouts(moduleAPIName) {
//example
//let moduleAPIName = "Leads";
//Get instance of LayoutsOperations Class that takes moduleAPIName as parameter
let layoutsOperations = new ZCRM.Layout.Operations(moduleAPIName);
//Call getLayouts method
let response = await layoutsOperations.getLayouts();
if (response != null) {
//Get the status code from response
console.log("Status Code: " + response.getStatusCode());
if ([204, 304].includes(response.getStatusCode())) {
console.log(response.getStatusCode() == 204 ? "No Content" : "Not Modified");
return;
}
//Get object from response
let responseObject = response.getObject();
if (responseObject != null) {
//Check if expected ResponseWrapper instance is received.
if (responseObject instanceof ZCRM.Layout.Model.ResponseWrapper) {
//Get the array of obtained Layout instances
let layouts = responseObject.getLayouts();
layouts.forEach(layout => {
if (layout.getCreatedTime() != null) {
//Get the CreatedTime of each Layout
console.log("Layout CreatedTime: " + layout.getCreatedTime().toString());
}
//Check if ConvertMapping is not null
if (layout.getConvertMapping() != null) {
//Get the ConvertMapping map
Array.from(layout.getConvertMapping().keys()).forEach(key => {
console.log(key + ": " + layout.getConvertMapping().get(key));
});
}
if (layout.getModifiedTime() != null) {
//Get the ModifiedTime of each Layout
console.log("Layout ModifiedTime: " + layout.getModifiedTime());
}
//Get the Visible of each Layout
console.log("Layout Visible: " + layout.getVisible().toString());
//Get the createdFor User instance of each Layout
let createdFor = layout.getCreatedFor();
//Check if createdFor is not null
if (createdFor != null) {
//Get the Name of the createdFor User
console.log("Layout CreatedFor User-Name: " + createdFor.getName());
//Get the ID of the createdFor User
console.log("Layout CreatedFor User-ID: " + createdFor.getId());
//Get the Email of the createdFor User
console.log("Layout CreatedFor User-Email: " + createdFor.getEmail());
}
//Get the Name of each Layout
console.log("Layout Name: " + layout.getName());
//Get the modifiedBy User instance of each Layout
let modifiedBy = layout.getModifiedBy();
//Check if modifiedBy is not null
if (modifiedBy != null) {
//Get the Name of the modifiedBy User
console.log("Layout ModifiedBy User-Name: " + modifiedBy.getName());
//Get the ID of the modifiedBy User
console.log("Layout ModifiedBy User-ID: " + modifiedBy.getId());
//Get the Email of the modifiedBy User
console.log("Layout ModifiedBy User-Email: " + modifiedBy.getEmail());
}
//Get the profiles of each Layout
let profiles = layout.getProfiles();
//Check if profiles is not null
if (profiles != null) {
profiles.forEach(profile => {
//Get the Default of each Profile
console.log("Layout Profile Default: " + profile.getDefault().toString());
//Get the Name of each Profile
console.log("Layout Profile Name: " + profile.getName().toString());
//Get the ID of each Profile
console.log("Layout Profile ID: " + profile.getId().toString());
});
}
//Get the ID of each Layout
console.log("Layout ID: " + layout.getId());
//Get the createdBy User instance of each Layout
let createdBy = layout.getCreatedBy();
//Check if createdBy is not null
if (createdBy != null) {
//Get the Name of the createdBy User
console.log("Layout CreatedBy User-Name: " + createdBy.getName());
//Get the ID of the createdBy User
console.log("Layout CreatedBy User-ID: " + createdBy.getId());
//Get the Email of the createdBy User
console.log("Layout CreatedBy User-Email: " + createdBy.getEmail());
}
//Get the sections of each Layout
let sections = layout.getSections();
//Check if sections is not null
if (sections != null) {
sections.forEach(section => {
//Get the DisplayLabel of each Section
console.log("Layout Section DisplayLabel: " + section.getDisplayLabel());
//Get the SequenceNumber of each Section
console.log("Layout Section SequenceNumber: " + section.getSequenceNumber().toString());
//Get the Issubformsection of each Section
console.log("Layout Section Issubformsection: " + section.getIssubformsection().toString());
//Get the TabTraversal of each Section
console.log("Layout Section TabTraversal: " + section.getTabTraversal().toString());
//Get the APIName of each Section
console.log("Layout Section APIName: " + section.getAPIName());
//Get the ColumnCount of each Section
console.log("Layout Section ColumnCount: " + section.getColumnCount().toString());
//Get the Name of each Section
console.log("Layout Section Name: " + section.getName());
//Get the GeneratedType of each Section
console.log("Layout Section GeneratedType: " + section.getGeneratedType());
//Get the fields of each Section
let fields = section.getFields();
//Check if fields is not null
if (fields != null) {
for (let index = 0; index {
console.log(key + ": " + details.get(key));
});
}
//Get the Message
console.log("Message: " + responseObject.getMessage().getValue());
}
}
}
}
}
Get a Layout
class Layout
{
/**
* Get Layout
* This method is used to get metadata about a single layout of a module with layoutID and print the response.
* @param {String} moduleAPIName The API Name of the layout's modules
* @param {BigInt} layoutId The ID of the layout to be obtained
*/
static async getLayout(moduleAPIName, layoutId) {
//example
//let moduleAPIName = "Leads";
//let layoutId = 34770610091055n;
//Get instance of LayoutsOperations Class that takes moduleAPIName as parameter
let layoutsOperations = new ZCRM.Layout.Operations(moduleAPIName);
//Call getLayout method
let response = await layoutsOperations.getLayout(layoutId);
if (response != null) {
//Get the status code from response
console.log("Status Code: " + response.getStatusCode());
if ([204, 304].includes(response.getStatusCode())) {
console.log(response.getStatusCode() == 204 ? "No Content" : "Not Modified");
return;
}
//Get object from response
let responseObject = response.getObject();
if (responseObject != null) {
//Check if expected ResponseWrapper instance is received.
if (responseObject instanceof ZCRM.Layout.Model.ResponseWrapper) {
let layouts = responseObject.getLayouts();
layouts.forEach(layout => {
if (layout.getCreatedTime() != null) {
//Get the CreatedTime of each Layout
console.log("Layout CreatedTime: " + layout.getCreatedTime().toString());
}
//Check if ConvertMapping is not null
if (layout.getConvertMapping() != null) {
//Get the MultiModuleLookup map
Array.from(layout.getConvertMapping().keys()).forEach(key => {
console.log(key + ": " + layout.getConvertMapping().get(key));
});
}
if (layout.getModifiedTime() != null) {
//Get the ModifiedTime of each Layout
console.log("Layout ModifiedTime: " + layout.getModifiedTime());
}
//Get the Visible of each Layout
console.log("Layout Visible: " + layout.getVisible().toString());
//Get the createdFor User instance of each Layout
let createdFor = layout.getCreatedFor();
//Check if createdFor is not null
if (createdFor != null) {
//Get the Name of the createdFor User
console.log("Layout CreatedFor User-Name: " + createdFor.getName());
//Get the ID of the createdFor User
console.log("Layout CreatedFor User-ID: " + createdFor.getId());
//Get the Email of the createdFor User
console.log("Layout CreatedFor User-Email: " + createdFor.getEmail());
}
//Get the Name of each Layout
console.log("Layout Name: " + layout.getName());
//Get the modifiedBy User instance of each Layout
let modifiedBy = layout.getModifiedBy();
//Check if modifiedBy is not null
if (modifiedBy != null) {
//Get the Name of the modifiedBy User
console.log("Layout ModifiedBy User-Name: " + modifiedBy.getName());
//Get the ID of the modifiedBy User
console.log("Layout ModifiedBy User-ID: " + modifiedBy.getId());
//Get the Email of the modifiedBy User
console.log("Layout ModifiedBy User-Email: " + modifiedBy.getEmail());
}
//Get the profiles of each Layout
let profiles = layout.getProfiles();
//Check if profiles is not null
if (profiles != null) {
profiles.forEach(profile => {
//Get the Default of each Profile
console.log("Layout Profile Default: " + profile.getDefault().toString());
//Get the Name of each Profile
console.log("Layout Profile Name: " + profile.getName().toString());
//Get the ID of each Profile
console.log("Layout Profile ID: " + profile.getId().toString());
});
}
//Get the ID of each Layout
console.log("Layout ID: " + layout.getId());
//Get the createdBy User instance of each Layout
let createdBy = layout.getCreatedBy();
//Check if createdBy is not null
if (createdBy != null) {
//Get the Name of the createdBy User
console.log("Layout CreatedBy User-Name: " + createdBy.getName());
//Get the ID of the createdBy User
console.log("Layout CreatedBy User-ID: " + createdBy.getId());
//Get the Email of the createdBy User
console.log("Layout CreatedBy User-Email: " + createdBy.getEmail());
}
//Get the sections of each Layout
let sections = layout.getSections();
//Check if sections is not null
if (sections != null) {
sections.forEach(section => {
//Get the DisplayLabel of each Section
console.log("Layout Section DisplayLabel: " + section.getDisplayLabel());
//Get the SequenceNumber of each Section
console.log("Layout Section SequenceNumber: " + section.getSequenceNumber().toString());
//Get the Issubformsection of each Section
console.log("Layout Section Issubformsection: " + section.getIssubformsection().toString());
//Get the TabTraversal of each Section
console.log("Layout Section TabTraversal: " + section.getTabTraversal().toString());
//Get the APIName of each Section
console.log("Layout Section APIName: " + section.getAPIName());
//Get the ColumnCount of each Section
console.log("Layout Section ColumnCount: " + section.getColumnCount().toString());
//Get the Name of each Section
console.log("Layout Section Name: " + section.getName());
//Get the GeneratedType of each Section
console.log("Layout Section GeneratedType: " + section.getGeneratedType());
//Get the fields of each Section
let fields = section.getFields();
//Check if fields is not null
if (fields != null) {
for (let index = 0; index {
console.log(key + ": " + details.get(key));
});
}
//Get the Message
console.log("Message: " + responseObject.getMessage().getValue());
}
}
}
}
}