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
Tejender Mohan 9Tejender Mohan 9 

How can we use a variable as “string[] fullNames” on readMetadata?

Hello Everyone,

Below given is the syntax for readMetadata call for fetching WorkflowRule specific to an object .
ReadResult = metadataConnection.readMetadata(string WorkflowRule, string[] fullNames);
I want to know that Is there any way to use a variable(which has the object name) in place of "string[] fullNames" ?

Below is the code snippet from my code,
while I am trying to execute it , it gives NULL for mdInfoWorkflow.fullname
Note: Cobj is a FileProperties type list of all object
.... for (MetadataService.FileProperties n : Cobj)
 { readResultWorkflow = service.readMetadata('WorkflowRule', new String[] {n.fullname}); 
mdInfoWorkflow = readResultWorkflow.getRecords(); system.debug('mdInfoWorkflow :' +mdInfoWorkflow); ...

Please suggest.
Thanks in Advance :)
 
NagendraNagendra (Salesforce Developers) 
Hi Tejendar,

You can use any list of strings you want.

These two syntaxes are identical:
List<String> aNames = new List<String>(); String[] bNames = new String[](); aNames.add('Workflow_A'); bNames.add('Workflow_B');
You can also instantiate them with elements inline:
List<String> aNames = new List<String> { 'Workflow_A' }; String[] bNames = new String[] { 'Workflow_B' };

Please mark this as solved if the information helps so that it results in helping others who are encountering a similar issue.

Best Regards,
Nagendra.