I am trying to fetch an existing Page Layout using the Java client for the Metadata API, in order to update it.
However, I don't think I can properly fetch it, as it is NULL.
Here is my code:
ReadResult readMetadataResult1 = metadataConnection.readMetadata("Layout", new String[] { "bpgdev__test__c-testLayout" });
ReadResult readMetadataResult2 = metadataConnection.readMetadata("Layout", new String[] { "test__c-testLayout" });
System.out.println(readMetadataResult1.getRecords().length);//prints 1
System.out.println(readMetadataResult2.getRecords().length);//prints 1
Layout layout1 = (Layout)readMetadataResult1.getRecords()[0];//layout1 is NULL
Layout layout2 = (Layout)readMetadataResult2.getRecords()[0];//layout2 is NULL
And my page layout is definitely returned by a listMetadata call. Here is my code for that:
ListMetadataQuery query = new ListMetadataQuery();
query.setType("Layout");
FileProperties []fileProperties = metadataConnection.listMetadata(new ListMetadataQuery[]{query}, 42.0);
for(FileProperties prop: fileProperties){
System.out.println(prop.getFullName());//outputs test__c-testLayout amongst others
}
Can anyone give me any ideas as to what I am missing?
I have tried both with and without namespace, none working.