File tree Expand file tree Collapse file tree 1 file changed +11
-12
lines changed
Expand file tree Collapse file tree 1 file changed +11
-12
lines changed Original file line number Diff line number Diff line change @@ -176,18 +176,17 @@ export interface OrgOpenOutput {
176176 orgId : string ;
177177}
178178
179- /** query the tooling API to turn a flow's filepath into a FlowId (starts with 301) */
179+ /** query the rest API to turn a flow's filepath into a FlowId (starts with 301) */
180180const flowFileNameToId = async ( conn : Connection , filePath : string ) : Promise < string > => {
181- const result = await conn . tooling . query < { Id : string ; FullName : string } > (
182- 'select id, MasterLabel, FullName from Flow'
183- ) ;
184- const fullName = path . basename ( filePath ) . replace ( '.flow-meta.xml' , '' ) ;
185- // https://developer.salesforce.com/docs/atlas.en-us.api_tooling. meta/api_tooling/tooling_api_objects_flow.htm
186- // unfortunately, you can't query based on the fullname because `field 'FullName' can not be filtered in a query call `
187- // so we get all the flows and then filter.
188- const match = ( result . records ?? [ ] ) . find ( ( r ) => r . FullName === fullName ) ?. Id ;
189- if ( match ) {
190- return match ;
181+ try {
182+ const flow = await conn . singleRecordQuery < { DurableId : string } > (
183+ `SELECT DurableId FROM FlowVersionView WHERE FlowDefinitionView.ApiName = ' ${ path . basename (
184+ filePath ,
185+ '.flow- meta.xml'
186+ ) } ' ORDER BY VersionNumber DESC LIMIT 1 `
187+ ) ;
188+ return flow . DurableId ;
189+ } catch ( error ) {
190+ throw messages . createError ( 'FlowIdNotFound' , [ filePath ] ) ;
191191 }
192- throw messages . createError ( 'FlowIdNotFound' , [ filePath ] ) ;
193192} ;
You can’t perform that action at this time.
0 commit comments