function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
kosmitevkosmitev 

Finding layout names

Hi,

Does anybody know a way to find the layout names per an sObject.

I have looked at describeLayout but that gives you everything but the name - very weird.

 

Thanks,

Kos

Best Answer chosen by Admin (Salesforce Developers) 
kosmitevkosmitev

To answer my own question:

After contacting a salesforce representative the soliution is to use the metadata API. In C#.Net it looks something like:

ListMetadataQuery query = new ListMetadataQuery();
query.Type = "Layout";
ListMetadataQuery[] queries = new ListMetadataQuery[] {query};
MetadataService service = new MetadataService();
FileProperties [] fileProps = service.listMetadata(queries,21.0);
foreach(FileProperties prop in fileProps)
{
    int dashIndex = fileProp.fullName.IndexOf("-");
    string sObjName = fileProp.fullName.substring(0,dashInde   x);
    string layoutName = fileProp.fullName.substrign(dashIndex + 1);
    string layoutId = fileProp.id;
}

 

Kos

All Answers

kosmitevkosmitev

To answer my own question:

After contacting a salesforce representative the soliution is to use the metadata API. In C#.Net it looks something like:

ListMetadataQuery query = new ListMetadataQuery();
query.Type = "Layout";
ListMetadataQuery[] queries = new ListMetadataQuery[] {query};
MetadataService service = new MetadataService();
FileProperties [] fileProps = service.listMetadata(queries,21.0);
foreach(FileProperties prop in fileProps)
{
    int dashIndex = fileProp.fullName.IndexOf("-");
    string sObjName = fileProp.fullName.substring(0,dashInde   x);
    string layoutName = fileProp.fullName.substrign(dashIndex + 1);
    string layoutId = fileProp.id;
}

 

Kos

This was selected as the best answer
taralextaralex

There's no 'MetadataService' object in my wsdl, what did I do wrong?