Thank You For Flows, and An Example of Their Use

@George, @Teodor, @patrick

:tada: THANK YOU FOR FLOWS! :tada:

After some challenges grappling with them not saving properly, which was finally fixed by uninstalling and re-installing Wappler, I’m having great success with flows, having just completed one with 18 sets of double conditionals which works like a dream.

Each double conditional was quite complex and then the 18 different ones were very very similar. I used the Flow user interface to create the first one, test it and duplicated it 18 times, and then I just edited the small changes to each one in the HTML code. That way, I know each one is in exactly the same format, and I find it easier and more reliable than creating each of the 36 conditions and actions in the menu system. It was all very fast and very smooth!

The complete flow is nearly 600 lines of code… but many of those lines are just closing brackets for the different conditions.

If you are interested in what it does and to see the code, I’ve pasted the details below.

Thanks folks!

Antony.

=================================

So I am creating a large business admin app, and within that there are 18 different “lookup” values which the user can modify to change what appears in different drop down menus… different tags, groupings, etc.

Once a lookup is defined and then associated with an item in the database (so a contact tag is defined and has been associated with a contact for example), then I don’t want the user to be able to delete the lookup. Hence the Flow checks for the use of all 18 different kinds of lookups and only allows deletion if that particular value has not been used.

Here is the code!

<script is="dmx-flow" id="flow_show_delete_lookup_modal" type="text/dmx-flow">{
  meta: {
    $param: [
      {type: "text", name: "id"},
      {type: "text", name: "lookup_name"},
      {type: "text", name: "lookup_type"}
    ]
  },
  exec: {
    steps: [
      {
        run: {
          action: "{{m_lookup_id_to_delete.setValue($param.id)}}",
          name: "set_m_lookup_id"
        }
      },
      {
        run: {
          action: "{{m_lookup_name_to_delete.setValue($param.lookup_name)}}",
          name: "set_m_lookup_name"
        }
      },
      {
        run: {
          action: "{{m_lookup_type_to_delete.setValue($param.lookup_type)}}",
          name: "set_m_lookup_type"
        }
      },
      {
        run: {action: "{{m_lookup_can_delete.setValue(0)}}", name: "can_delete_0"}
      },
      {
        comment: {msg: "ACTIVITY TAG"}
      },
      {
        condition: {
          if: "{{($param.lookup_type == 1)}}",
          then: {
            steps: [
              {
                serverConnect: {
                  url: "dmxConnect/api/lookups/count_activity_tag.php",
                  params: {id: "{{$param.id}}"},
                  name: "scf_count_activity_tag"
                }
              },
              {
                condition: {
                  if: "{{(scf_count_activity_tag.data.count.count() == 0)}}",
                  then: {
                    steps: {
                      run: {action: "{{m_lookup_can_delete.setValue(1)}}", name: ""}
                    }
                  },
                  else: {
                    steps: {
                      run: {
                        action: "{{notification.info(scf_count_activity_tag.data.count.count())}}"
                      }
                    }
                  }
                }
              }
            ]
          }
        }
      },
      {
        comment: {msg: "ACTIVITY TYPE"}
      },
      {
        condition: {
          if: "{{($param.lookup_type == 2)}}",
          then: {
            steps: [
              {
                serverConnect: {
                  url: "dmxConnect/api/lookups/count_activity_type.php",
                  params: {id: "{{$param.id}}"},
                  name: "scf_count_activity_type"
                }
              },
              {
                condition: {
                  if: "{{(scf_count_activity_type.data.count.count() == 0)}}",
                  then: {
                    steps: {
                      run: {action: "{{m_lookup_can_delete.setValue(1)}}", name: ""}
                    }
                  },
                  else: {
                    steps: {
                      run: {
                        action: "{{notification.info(scf_count_activity_type.data.count.count())}}"
                      }
                    }
                  }
                }
              }
            ]
          }
        }
      },
      {
        comment: {msg: "CONTACT TAG"}
      },
      {
        condition: {
          if: "{{($param.lookup_type == 10)}}",
          then: {
            steps: [
              {
                serverConnect: {
                  url: "dmxConnect/api/lookups/count_contact_tag.php",
                  params: {id: "{{$param.id}}"},
                  name: "scf_count_contact_tag"
                }
              },
              {
                condition: {
                  if: "{{(scf_count_contact_tag.data.count.count() == 0)}}",
                  then: {
                    steps: {
                      run: {action: "{{m_lookup_can_delete.setValue(1)}}", name: ""}
                    }
                  },
                  else: {
                    steps: {
                      run: {action: "{{notification.info(scf_count_contact_tag.data.count.count())}}"}
                    }
                  }
                }
              }
            ]
          }
        }
      },
      {
        comment: {msg: "CONTACT REGION"}
      },
      {
        condition: {
          if: "{{($param.lookup_type == 11)}}",
          then: {
            steps: [
              {
                serverConnect: {
                  url: "dmxConnect/api/lookups/count_contact_region.php",
                  params: {id: "{{$param.id}}"},
                  name: "scf_count_contact_region"
                }
              },
              {
                condition: {
                  if: "{{(scf_count_contact_region.data.count.count() == 0)}}",
                  then: {
                    steps: {
                      run: {action: "{{m_lookup_can_delete.setValue(1)}}", name: ""}
                    }
                  },
                  else: {
                    steps: {
                      run: {action: "{{notification.info(scf_count_contact_region.data.count.count())}}"}
                    }
                  }
                }
              }
            ]
          }
        }
      },
      {
        comment: {msg: "GENDER"}
      },
      {
        condition: {
          if: "{{($param.lookup_type == 12)}}",
          then: {
            steps: [
              {
                serverConnect: {
                  url: "dmxConnect/api/lookups/count_gender.php",
                  params: {id: "{{$param.id}}"},
                  name: "scf_count_gender"
                }
              },
              {
                condition: {
                  if: "{{(scf_count_gender.data.count.count() == 0)}}",
                  then: {
                    steps: {
                      run: {action: "{{m_lookup_can_delete.setValue(1)}}", name: ""}
                    }
                  },
                  else: {
                    steps: {
                      run: {action: "{{notification.info(scf_count_gender.data.count.count())}}"}
                    }
                  }
                }
              }
            ]
          }
        }
      },
      {
        comment: {msg: "AGE_RANGE"}
      },
      {
        condition: {
          if: "{{($param.lookup_type == 13)}}",
          then: {
            steps: [
              {
                serverConnect: {
                  url: "dmxConnect/api/lookups/count_age_range.php",
                  params: {id: "{{$param.id}}"},
                  name: "scf_count_age_range"
                }
              },
              {
                condition: {
                  if: "{{(scf_count_age_range.data.count.count() == 0)}}",
                  then: {
                    steps: {
                      run: {action: "{{m_lookup_can_delete.setValue(1)}}", name: ""}
                    }
                  },
                  else: {
                    steps: {
                      run: {
                        action: "{{notification.info(scf_count_age_range.data.count.count())}}"
                      }
                    }
                  }
                }
              }
            ]
          }
        }
      },
      {
        comment: {msg: "PAYMENT METHOD"}
      },
      {
        condition: {
          if: "{{($param.lookup_type == 20)}}",
          then: {
            steps: [
              {
                serverConnect: {
                  url: "dmxConnect/api/lookups/count_payment_method.php",
                  params: {id: "{{$param.id}}"},
                  name: "scf_count_payment_method"
                }
              },
              {
                condition: {
                  if: "{{(scf_count_payment_method.data.count.count() == 0)}}",
                  then: {
                    steps: {
                      run: {action: "{{m_lookup_can_delete.setValue(1)}}", name: ""}
                    }
                  },
                  else: {
                    steps: {
                      run: {
                        action: "{{notification.info(scf_count_payment_method.data.count.count())}}"
                      }
                    }
                  }
                }
              }
            ]
          }
        }
      },
      {
        comment: {msg: "EXPENSE PAYMENT METHOD"}
      },
      {
        condition: {
          if: "{{($param.lookup_type == 21)}}",
          then: {
            steps: [
              {
                serverConnect: {
                  url: "dmxConnect/api/lookups/count_expense_payment_method.php",
                  params: {id: "{{$param.id}}"},
                  name: "scf_count_expense_payment_method"
                }
              },
              {
                condition: {
                  if: "{{(scf_count_expense_payment_method.data.count.count() == 0)}}",
                  then: {
                    steps: {
                      run: {action: "{{m_lookup_can_delete.setValue(1)}}", name: ""}
                    }
                  },
                  else: {
                    steps: {
                      run: {
                        action: "{{notification.info(scf_count_expense_payment_method.data.count.count())}}"
                      }
                    }
                  }
                }
              }
            ]
          }
        }
      },
      {
        comment: {msg: "EXPENSE CATEGORY"}
      },
      {
        condition: {
          if: "{{($param.lookup_type == 22)}}",
          then: {
            steps: [
              {
                serverConnect: {
                  url: "dmxConnect/api/lookups/count_expense_category.php",
                  params: {id: "{{$param.id}}"},
                  name: "scf_count_expense_category"
                }
              },
              {
                condition: {
                  if: "{{(scf_count_expense_category.data.count.count() == 0)}}",
                  then: {
                    steps: {
                      run: {action: "{{m_lookup_can_delete.setValue(1)}}", name: ""}
                    }
                  },
                  else: {
                    steps: {
                      run: {
                        action: "{{notification.info(scf_count_expense_category.data.count.count())}}"
                      }
                    }
                  }
                }
              }
            ]
          }
        }
      },
      {
        comment: {msg: "EXPENSE SUB CATEGORY"}
      },
      {
        condition: {
          if: "{{($param.lookup_type == 23)}}",
          then: {
            steps: [
              {
                serverConnect: {
                  url: "dmxConnect/api/lookups/count_expense_sub_category.php",
                  params: {id: "{{$param.id}}"},
                  name: "scf_count_expense_sub_category"
                }
              },
              {
                condition: {
                  if: "{{(scf_count_expense_sub_category.data.count.count() == 0)}}",
                  then: {
                    steps: {
                      run: {action: "{{m_lookup_can_delete.setValue(1)}}", name: ""}
                    }
                  },
                  else: {
                    steps: {
                      run: {
                        action: "{{notification.info(scf_count_expense_sub_category.data.count.count())}}"
                      }
                    }
                  }
                }
              }
            ]
          }
        }
      },
      {
        comment: {msg: "PRICE TYPE"}
      },
      {
        condition: {
          if: "{{($param.lookup_type == 30)}}",
          then: {
            steps: [
              {
                serverConnect: {
                  url: "dmxConnect/api/lookups/count_price_type.php",
                  params: {id: "{{$param.id}}"},
                  name: "scf_count_price_type"
                }
              },
              {
                condition: {
                  if: "{{(scf_count_price_type.data.count.count() == 0)}}",
                  then: {
                    steps: {
                      run: {action: "{{m_lookup_can_delete.setValue(1)}}", name: ""}
                    }
                  },
                  else: {
                    steps: {
                      run: {
                        action: "{{notification.info(scf_count_price_type.data.count.count())}}"
                      }
                    }
                  }
                }
              }
            ]
          }
        }
      },
      {
        comment: {msg: "PRICE GROUP"}
      },
      {
        condition: {
          if: "{{($param.lookup_type == 31)}}",
          then: {
            steps: [
              {
                serverConnect: {
                  url: "dmxConnect/api/lookups/count_price_group.php",
                  params: {id: "{{$param.id}}"},
                  name: "scf_count_price_group"
                }
              },
              {
                condition: {
                  if: "{{(scf_count_price_group.data.count.count() == 0)}}",
                  then: {
                    steps: {
                      run: {action: "{{m_lookup_can_delete.setValue(1)}}", name: ""}
                    }
                  },
                  else: {
                    steps: {
                      run: {
                        action: "{{notification.info(scf_count_price_group.data.count.count())}}"
                      }
                    }
                  }
                }
              }
            ]
          }
        }
      },
      {
        comment: {msg: "OE PRICE GROUP"}
      },
      {
        condition: {
          if: "{{($param.lookup_type == 32)}}",
          then: {
            steps: [
              {
                serverConnect: {
                  url: "dmxConnect/api/lookups/count_optional_extra_price_group.php",
                  params: {id: "{{$param.id}}"},
                  name: "scf_count_optional_extra_price_group"
                }
              },
              {
                condition: {
                  if: "{{(scf_count_optional_extra_price_group.data.count.count() == 0)}}",
                  then: {
                    steps: {
                      run: {action: "{{m_lookup_can_delete.setValue(1)}}", name: ""}
                    }
                  },
                  else: {
                    steps: {
                      run: {
                        action: "{{notification.info(scf_count_optional_extra_price_group.data.count.count())}}"
                      }
                    }
                  }
                }
              }
            ]
          }
        }
      },
      {
        comment: {msg: "MAILING MESSAGE COLLECTION"}
      },
      {
        condition: {
          if: "{{($param.lookup_type == 40)}}",
          then: {
            steps: [
              {
                serverConnect: {
                  url: "dmxConnect/api/lookups/count_mailing_message_collection.php",
                  params: {id: "{{$param.id}}"},
                  name: "scf_count_mailing_message_collection"
                }
              },
              {
                condition: {
                  if: "{{(scf_count_mailing_message_collection.data.count.count() == 0)}}",
                  then: {
                    steps: {
                      run: {action: "{{m_lookup_can_delete.setValue(1)}}", name: ""}
                    }
                  },
                  else: {
                    steps: {
                      run: {
                        action: "{{notification.info(scf_count_mailing_message_collection.data.count.count())}}"
                      }
                    }
                  }
                }
              }
            ]
          }
        }
      },
      {
        comment: {msg: "REUSABLE TEXT COLLECTION"}
      },
      {
        condition: {
          if: "{{($param.lookup_type == 41)}}",
          then: {
            steps: [
              {
                serverConnect: {
                  url: "dmxConnect/api/lookups/count_reusable_text_collection.php",
                  params: {id: "{{$param.id}}"},
                  name: "scf_count_reusable_text_collection"
                }
              },
              {
                condition: {
                  if: "{{(scf_count_reusable_text_collection.data.count.count() == 0)}}",
                  then: {
                    steps: {
                      run: {action: "{{m_lookup_can_delete.setValue(1)}}", name: ""}
                    }
                  },
                  else: {
                    steps: {
                      run: {
                        action: "{{notification.info(scf_count_reusable_text_collection.data.count.count())}}"
                      }
                    }
                  }
                }
              }
            ]
          }
        }
      },
      {
        comment: {msg: "QUESTION TOPIC"}
      },
      {
        condition: {
          if: "{{($param.lookup_type == 50)}}",
          then: {
            steps: [
              {
                serverConnect: {
                  url: "dmxConnect/api/lookups/count_question_topic.php",
                  params: {id: "{{$param.id}}"},
                  name: "scf_count_question_topic"
                }
              },
              {
                condition: {
                  if: "{{(scf_count_question_topic.data.count.count() == 0)}}",
                  then: {
                    steps: {
                      run: {action: "{{m_lookup_can_delete.setValue(1)}}", name: ""}
                    }
                  },
                  else: {
                    steps: {
                      run: {
                        action: "{{notification.info(scf_count_question_topic.data.count.count())}}"
                      }
                    }
                  }
                }
              }
            ]
          }
        }
      },
      {
        comment: {msg: "QUESTION GROUP"}
      },
      {
        condition: {
          if: "{{($param.lookup_type == 51)}}",
          then: {
            steps: [
              {
                serverConnect: {
                  url: "dmxConnect/api/lookups/count_question_group.php",
                  params: {id: "{{$param.id}}"},
                  name: "scf_count_question_group"
                }
              },
              {
                condition: {
                  if: "{{(scf_count_question_group.data.count.count() == 0)}}",
                  then: {
                    steps: {
                      run: {action: "{{m_lookup_can_delete.setValue(1)}}", name: ""}
                    }
                  },
                  else: {
                    steps: {
                      run: {
                        action: "{{notification.info(scf_count_question_group.data.count.count())}}"
                      }
                    }
                  }
                }
              }
            ]
          }
        }
      },
      {
        comment: {msg: "RESPONSE GROUP"}
      },
      {
        condition: {
          if: "{{($param.lookup_type == 52)}}",
          then: {
            steps: [
              {
                serverConnect: {
                  url: "dmxConnect/api/lookups/count_response_group.php",
                  params: {id: "{{$param.id}}"},
                  name: "scf_count_response_group"
                }
              },
              {
                condition: {
                  if: "{{(scf_count_response_group.data.count.count() == 0)}}",
                  then: {
                    steps: {
                      run: {action: "{{m_lookup_can_delete.setValue(1)}}", name: ""}
                    }
                  },
                  else: {
                    steps: {
                      run: {
                        action: "{{notification.info(scf_count_response_group.data.count.count())}}"
                      }
                    }
                  }
                }
              }
            ]
          }
        }
      },
      {
        run: {action: "{{m_delete_lookup.show()}}", name: "show_modal"}
      }
    ]
  }
}</script>
Community Page
Last updated: