-
Notifications
You must be signed in to change notification settings - Fork 992
Open
Description
Hi Team,
I’m trying to update page layouts by adding a custom action and some fields using the Metadata API. However, I'm encountering an issue where readMetadata() is returning null values, and I'm unable to proceed further.
Here’s the error I’m receiving: System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: UNKNOWN_EXCEPTION: An unexpected error occurred. Please include this ErrorId if you contact support: 885255747-237006 (1807525792) faultcode=sf:UNKNOWN_EXCEPTION faultactor=
Below is the code snippet I’m using:
public static void addButton(){
MetadataService.MetadataPort mdpService = createService();
MetadataService.Layout objLayout = (MetadataService.Layout) mdpService.readMetadata('Layout',new String[] { 'Account-Account Layout' }).getRecords()[0];
System.debug(JSON.serializePretty(mdpService.readMetadata('Layout',new String[] { 'Account-fno_sf_conn__Account Layout' }).getRecords()));
System.debug(JSON.serializePretty(objLayout));
if (objLayout.platformActionList == null) {
objLayout.platformActionList = new MetadataService.platformActionList();
objLayout.platformActionList.actionListContext = 'Record';
}
if (objLayout.platformActionList.platformActionListItems == null) {
objLayout.platformActionList.platformActionListItems = new List<MetadataService.PlatformActionListItem>();
}
MetadataService.PlatformActionListItem objPlateformActionListItem = new MetadataService.PlatformActionListItem();
objPlateformActionListItem.actionName ='Account.fno_sf_conn__Sync_with_FNO';
objPlateformActionListItem.actionType = 'QuickAction';
objPlateformActionListItem.sortOrder = 50;
objPlateformActionListItem.subtype = null;
objLayout.platformActionList.platformActionListItems.add(objPlateformActionListItem);
//List<MetadataService.Metadata> lstLayoutsToUpdate = new List<MetadataService.Metadata>{objLayout};
List<MetadataService.SaveResult> lstSaveResults = mdpService.updateMetadata(new MetadataService.Metadata[] { objLayout });
}
Metadata
Metadata
Assignees
Labels
No labels