I am trying to insert queues using metadata api but getting error while inserting sobject in the queue.
MetadataService.QueueSobject obj =new MetadataService.QueueSobject();
obj.sobjectType='Account';
MetadataService.Queue queue = new MetadataService.Queue();
queue.fullName = 'Account_Queue';
queue.name = 'Account_Queue';
System.debug('*****Selected Object*****'+obj.sobjectType); // getting value here.
queue.queueSobject[0].sobjectType = obj.sobjectType; // Getting attempt to de-refrence null object
MetadataService.MetadataPort service = createService();
List<MetadataService.SaveResult> results = service.createMetadata(new
MetadataService.Metadata[] { queue });
handleSaveResults(results[0]);
queue.queueSobject[0].sobjectType = obj.sobjectType; -- This line throwing error.
obj.sobjectType is not getting stored in queue.queueSobject[0].sobjectType. How can I fix it ?
queue.queueSobject.sObjectType
are Case, Lead, serviceContract and custom objects. Please check Queue Metadata Guide