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
Amit MAmit M 

Created Flow using Metadata API but unable to see it in Salesforce

Hi I have created a flow using following code

 

MetadataService.MetadataPort service = createService();
MetadataService.Flow flow = new MetadataService.Flow();
flow.fullName = 'My_Flow-1';
flow.label = 'My Flow';
flow.description= 'This is a test floe';
flow.metaType='Flow';
//flow.type_x='';
MetadataService.FlowStep step = new MetadataService.FlowStep();
//step.metaType = 'FlowStep';
step.label='mylabel';
step.locationX=100;
step.locationY = 10;
step.description = 'Step description';
step.name='test step';

//MetadataService.AsyncResult[] results2 = service.create(new MetadataService.FlowStep[] { step });

flow.steps = new MetadataService.FlowStep[]{step};

//MetadataService.AsyncResult[] results = service.create(new List<MetadataService.Metadata> { flow });
MetadataService.AsyncResult[] results = service.create(new MetadataService.Flow[] { flow });

 

I get an id like 04sd0000002iQXvAAM in AsyncResult. But I am unable to see the flow in Salesforce.

 

2ndly, Can you also tell me how do i get the id with which I can access the flow using url like https://na14.salesforce.com/04sd0000002iQXvAAM

 

Thanks

Amit

Amit MAmit M

I have modified my code like this..

 

MetadataService.MetadataPort service = createService();
MetadataService.Flow flow = new MetadataService.Flow();
flow.fullName = 'My_Flow-1';
flow.label = 'My Flow';
flow.description= 'This is a test floe';
flow.metaType='Flow';
//flow.type_x='';
MetadataService.FlowStep step = new MetadataService.FlowStep();
//step.metaType = 'FlowStep';
step.label='mylabel';
step.locationX=100;
step.locationY = 10;
step.description = 'Step description';
step.name='test step';

//MetadataService.AsyncResult[] results2 = service.create(new MetadataService.FlowStep[] { step });

flow.steps = new MetadataService.FlowStep[]{step};

//MetadataService.AsyncResult[] results = service.create(new List<MetadataService.Metadata> { flow });
MetadataService.AsyncResult[] results = service.create(new MetadataService.Flow[] { flow });
do{
results = service.checkStatus(new String[] { results[0].id });
}while(!results[0].done);
System.debug('message================='+results[0].message);
return results[0].id+'?message='+results[0].message+'&statusCode='+results[0].statusCode;

 

No I am geeting a message like "


An unexpected error occurred. Please include this ErrorId if you contact support: 1460987326-60726 (-727292666)".

Any help will be highly appreciated.

Amit MAmit M

Hi,

I am able to see the Flow in the Salesforce now. But issue is that in the AsynchResult I am getting the object id as 04sd0000002iUccAAE. But when I open the Flow in the Salesforce I see the URL as https://na14.salesforce.com/300d0000000PpiI. My question is how do I get this id (300d0000000PpiI) in my Apex code.

Thanks

Amit

prakher jain 10prakher jain 10
where did you write this code if in apex can you shre your whole code