0

CODE:

MetadataService.MetadataPort service = new MetadataService.MetadataPort();
service.SessionHeader = new MetadataService.SessionHeader_element();
service.SessionHeader.sessionId = UserInfo.getSessionId();
MetadataService.FlowDefinition flow = 
    (MetadataService.FlowDefinition) 
        service.readMetadata('FlowDefinition',
                              new String[] {'test_flow-1' }).getRecords([0];
System.debug('Versionnumber ' + flow.activeVersionNumber);

kindly let me know what is wrong in my above code in salesforce?

ERROR:

Incompatible types since an instance of MetadataService.Metadata is never an instance of MetadataService.FlowDefinition

My main aim is to deactivate the flow ,according to the salesforce docs https://developer.salesforce.com/docs/atlas.en-us.api_meta.meta/api_meta/meta_flowdefinition.htm, we need to get the activeVersionNumber field of the FlowDefinition and set it to 0 to deactivate it.

  • What is your question? Are you asking to review the code or you are getting any errors? If you are getting errors, to be able to help, you need to post your error trace as well. – Jayant Das May 11 '18 at 12:35
  • yeah error I am getting is this that IncompatibleType Metadata class with FlowDefinition. Kindly help. – vineet May 11 '18 at 13:49
  • Exact error:----------------------------------------------------------Incompatible types since an instance of MetadataService.Metadata is never an instance of MetadataService.FlowDefinition – vineet May 11 '18 at 13:51
  • Can you please edit your original post and update it with the exception? – Jayant Das May 11 '18 at 13:55
  • yeah Jayant updated it. Thnx. – vineet May 11 '18 at 13:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.