Skip to main content

Data Factory

New

IF Activity inside IF Activity

Vote (1) Share
Samik Pal's profile image

Samik Pal on 12 Aug 2024 21:33:43

Currently, there is no way to set-up an IF Activity (inner) an IF Activity (outer). Th option to set up an inner IF is grayed out.




// pseudocode in javascript that shows the current options

let array = [1, 2, 3, 4, 5];

let db1 = db1;

let db2 = db2;


array.forEach((a, i) => {

   if (i < 4) {

       const newWatermark = newWatermark;

       const oldWatermark = oldWatermark;


       // Define fnCopyActivity parameters

       const copyParameters = [

           {

               source: {

                   connection: 'on_prem_sql',

                   query: `select * from \`${db1}\` between old and new`

               }

           },

           {

               destination: {

                   connection: 'lakehouse',

                   files: 'Files/daily'

               }

           }

       ];

       // Execute copy activity

       const copyActivity = fnCopyActivity(copyParameters);


       // Execute notebook activity if copy succeeds

       const notebookActivity = (copyActivity === "success") ? fnNotebook(copyActivity) : null;


       // Execute KQL activity if notebookActivity succeeds

       const KQLActivity = (notebookActivity === "success") ? fnKQL(copyActivity) : null;


   } else {

       const newWatermark = newWatermark;

       const oldWatermark = oldWatermark;


       // Define fnCopyActivity parameters

       const copyParameters = [

           {

               source: {

                   connection: 'on_prem_sql',

                   query: `select * from \`${db2}\` between old and new`

               }

           },

           {

               destination: {

                   connection: 'lakehouse',

                   files: 'Files/daily'

               }

           }

       ];


       // Execute copy activity

       const copyActivity = fnCopyActivity(copyParameters);


       // Execute notebook activity if copy succeeds

       const notebookActivity = (copyActivity === "success") ? fnNotebook(copyActivity) : null;


       // Execute KQL activity if notebookActivity succeeds

       const KQLActivity = (notebookActivity === "success") ? fnKQL(copyActivity) : null;

   }

});




But What I am looking for is this



let array = [1, 2, 3, 4, 5];

let db1 = db1;

let db2 = db2;


array.forEach((a, i) => {

   if (i < 4) {

       const newWatermark = newWatermark;

       const oldWatermark = oldWatermark;


       // Define fnCopyActivity parameters

       const copyParameters = [

           {

               source: {

                   connection: 'on_prem_sql',

                   query: `select * from \`${db1}\` between old and new`

               }

           },

           {

               destination: {

                   connection: 'lakehouse',

                   files: 'Files/daily'

               }

           }

       ];


       // NESTED IF that prevents further execution on condition check

       if (oldWatermark < newWatermark) {

           // Execute copy activity

           const copyActivity = fnCopyActivity(copyParameters);


           // Execute notebook activity if copy succeeds

           const notebookActivity = (copyActivity === "success") ? fnNotebook(copyActivity) : null;


           // Execute KQL activity if notebookActivity succeeds

           const KQLActivity = (notebookActivity === "success") ? fnKQL(copyActivity) : null;

       }


   } else {

       const newWatermark = newWatermark;

       const oldWatermark = oldWatermark;


       // Define fnCopyActivity parameters

       const copyParameters = [

           {

               source: {

                   connection: 'on_prem_sql',

                   query: `select * from \`${db2}\` between old and new`

               }

           },

           {

               destination: {

                   connection: 'lakehouse',

                   files: 'Files/daily'

               }

           }

       ];


       // NESTED IF that prevents further execution on condition check

       if (oldWatermark < newWatermark) {

           // Execute copy activity

           const copyActivity = fnCopyActivity(copyParameters);


           // Execute notebook activity if copy succeeds

           const notebookActivity = (copyActivity === "success") ? fnNotebook(copyActivity) : null;


           // Execute KQL activity if notebookActivity succeeds

           const KQLActivity = (notebookActivity === "success") ? fnKQL(copyActivity) : null;

       }

   }

});