0

I have 2 pipelines that are currently selected based on an IF condition, which works well. I now need to add a third pipeline , so using a Switch block instead. And instead of tablename as the deciding factor, ideally I would use logic something like this:

  1. does the sourcetablename value contain {FromDate} then goto pipeline A
  2. does the sourcetablename value contain {passinid} then goto pipeline B
  3. else goto pipeline C

The sourcetablename value comes with the initial gettablestoload lookup.

An example sourcetablename value is used for the API call in this instance, and would look like this for example: blahblah/content/{passinid}/user/blahblah

I am struggling with the expression for the switchblock. Previously I have matched on the last 10 characters of the tablename, this just seems a little bit tricky.

Here is an example of an expression to remove the last 46 characters, just to give you an idea where I am struggling up to:

@substring(activity('GetTablesToLoad').SourceTableName,0,sub(length(activity('GetTablesToLoad').SourceTableName),46))

Would anyone have an idea please?

If this was SQL it would be something like this:

 DECLARE @text VARCHAR (500) = 'content/{passinid}/user'
    SELECT SUBSTRING(@Text, CHARINDEX('{', @Text)
, CHARINDEX('}',@text) - CHARINDEX('{', @Text) + Len('}'))

switchblock

thankyou

user3735855
  • 144
  • 2
  • 20

1 Answers1

1

You can use if function to check for required value directly. I have taken a parameter called sourceTableName for demonstration instead of lookup value.

  • I have used the following dynamic content as expression value for switch activity. You can replace the pipeline().parameters.sourceTableName with lookup activity SourceTableName value. The name of switch case cannot start with { so, I have directly taken the name.
@if(contains(pipeline().parameters.sourceTableName,'{passinid}'),'passinid',if(contains(pipeline().parameters.sourceTableName,'{FromDate}'),'FromDate','execute default'))

enter image description here

  • When the parameter value is blahblah/content/{passinid}/user/blahblah, the corresponding set variable3 is executed.

enter image description here

  • When the parameter value is blahblah/content/{FromDate}/user/blahblah, the corresponding set variable4 is executed.

enter image description here

  • If these values are not present (blahblah/conten/user/blahblah), then the default case would be executed (set variable2 activity).

enter image description here

Saideep Arikontham
  • 5,558
  • 2
  • 3
  • 11
  • thankyou @SaideepArikontham for your comprehensive reply. I am in NZ so will apply this tomorrow - certainly looks awesome. Your illustrations are super helpful. – user3735855 Jan 25 '23 at 06:31
  • Used @if(contains(activity('GetTablesToLoad').output.value[0].SourceTableName,'{passinid}'),'passinid',if(contains(activity('GetTablesToLoad').output.value[0].SourceTableName,'{FromDate}'),'FromDate','execute default')) which works perfectly. – user3735855 Jan 25 '23 at 21:15