0

I am using metadata API to add picklist value('custom') in a field.I have a record type (AAM_T) created which has to be associated with value I have added to picklist, but as on running : service.updateMetadata( new MetadataService.Metadata[] { recordType }); causing an error 'System.CalloutException: IO Exception: Read timed out'.

MetadataService.PickListValue objPickListValue = new MetadataService.PickListValue();
objPickListValue.fullName = 'custom';
objPickListValue.default_x = false;

MetadataService.RecordType recordType = (MetadataService.RecordType) 
                                        service.readMetadata('RecordType',
                                        new String[] { 'Account.AAM_T'}).getRecords()[0];

MetadataService.RecordTypePicklistValue[] recordPickListType =  recordType.picklistValues;

if(recordPickListType.size() > 0){
   for(MetadataService.RecordTypePicklistValue rpk : recordPickListType) {
       if(rpk.picklist == picklistToUpdate){
            rpk.values.add(objPickListValue);
            break;
       }
    }

    try{
         service.updateMetadata( new MetadataService.Metadata[] { recordType });
       } catch(Exception ex){
          system.debug('@@@getStackTraceString : '+ex.getStackTraceString());
          //Result: System.CalloutException: IO Exception: Read timed out -- null
          system.debug('@@@getMessage : '+ex.getTypeName() 
                       + ': ' + ex.getMessage() + ' -- ' + ex.getCause());

        }

  }
  • Timeouts are OK-ish if your deployment has to run unit tests or trigger complex sharing changes for example. 1) have you verified it went ok/failed in the org itself? In setup -> deployment status? 2) You know you're supposed to get deployment's id and then you can keep polling for results, keep asking checkDeployStatus (https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_deploy.htm). – eyescream Aug 12 '19 at 15:11
  • If i am not wrong deployment status is related to file-based calls, as i am only updating a record type that does not require file-based calls.I followed the last example of Om Prakash (https://success.salesforce.com/answers?id=9063A000000pi0bQAA) , but as my record type is having multiple Picklist to edit which could be limiting Salesforce 160 Sec timeout of response from metadata API. – Kartik Sharma Aug 13 '19 at 06:29

1 Answers1

1

You can try this like any other webservice. worked to me

MetadataService.MetadataPort service = new MetadataService.MetadataPort();

service.timeout_x=120000;