SWITCH use it correctly?

SWITCH use it correctly?

  

Hi Everyone,

I am trying to use the switch function, but it doesn't work as i want. 

Do i use it wrong? 

First i have a CAT entity to store the data

On the Cats screen it will show the CAT

When i Press "OK" Button I hope it can jump to Food Screen or Shop Screen.

So I use SWITCH to help me 

I hope when i press OK it can get the current CATID, and switch can resolve where the CATID is 1 or 2 , Did I set the condition wrong? 

THANKS.

There are two different button for food and shop screen. You can use method of the button as navigate and then set your destination.

Example, when you click on the food ok button choose the method as navigate and set the destination Mainflow/Foods.

Hope this works for you!!!!

Priya Khade wrote:


Thanks Priya, I know the method you said, but i am trying a different way to do it. 

In the future the CAT data will become more and more, so I wonder the switch function can help or not.

THanks 

Hi Eva,

You haven't really explained what is the actual behaviour of your application there, what happens when you press each of those OK buttons?

But, a few considerations on what you are doing:

  • First of all, you should NEVER compare Ids with other data types (you will get warnings, just like you have on your Switch... if you really need to do it, use the Data Conversion built-in functions).
  • Second, you should NEVER compare Ids with statically defined values (like you are doing) as, most of the time, at design time you cannot be sure of what Id was assigned to what record.

Concerning how you want to evolve your implementation to support a growing number of Cats:

  • The Switch tool is static, as in, you won't be able to dynamically add new conditions to it as you grow your Cats... the developer will have to add them manually, one by one

Depending on your requirements, one possible approach could be for your CAT Entity to have an extra Attribute called URL, that you would fill with the Destination URL when you create a new record... when you display your Cats list, you use that URL as the destination of your Link/Button. That way, when you click on the Button you can navigate to the right place without any extra logic.

Jorge Martins wrote:

Hi Eva,

You haven't really explained what is the actual behaviour of your application there, what happens when you press each of those OK buttons?

But, a few considerations on what you are doing:

  • First of all, you should NEVER compare Ids with other data types (you will get warnings, just like you have on your Switch... if you really need to do it, use the Data Conversion built-in functions).
  • Second, you should NEVER compare Ids with statically defined values (like you are doing) as, most of the time, at design time you cannot be sure of what Id was assigned to what record.

Concerning how you want to evolve your implementation to support a growing number of Cats:

  • The Switch tool is static, as in, you won't be able to dynamically add new conditions to it as you grow your Cats... the developer will have to add them manually, one by one

Depending on your requirements, one possible approach could be for your CAT Entity to have an extra Attribute called URL, that you would fill with the Destination URL when you create a new record... when you display your Cats list, you use that URL as the destination of your Link/Button. That way, when you click on the Button you can navigate to the right place without any extra logic.

Thanks Jorge,

  What I want to do is press OK it will enter the Switch (like the case statement)

CASE Food Enter the Food screen;

CASE Shop Enter the Shop screen


And i will try your suggestion.

Thanks 



Jorge Martins wrote:

Hi Eva,

You haven't really explained what is the actual behaviour of your application there, what happens when you press each of those OK buttons?

But, a few considerations on what you are doing:

  • First of all, you should NEVER compare Ids with other data types (you will get warnings, just like you have on your Switch... if you really need to do it, use the Data Conversion built-in functions).
  • Second, you should NEVER compare Ids with statically defined values (like you are doing) as, most of the time, at design time you cannot be sure of what Id was assigned to what record.

Concerning how you want to evolve your implementation to support a growing number of Cats:

  • The Switch tool is static, as in, you won't be able to dynamically add new conditions to it as you grow your Cats... the developer will have to add them manually, one by one

Depending on your requirements, one possible approach could be for your CAT Entity to have an extra Attribute called URL, that you would fill with the Destination URL when you create a new record... when you display your Cats list, you use that URL as the destination of your Link/Button. That way, when you click on the Button you can navigate to the right place without any extra logic.

Hi Jorge,

For the last part,I am not quite understand ... I use the screen location as myURL?

Thanks 



Jorge Martins


HI Jorge, May I ask you about the URL as the destination of your Link/Button, I am not understand about it 

Thank you


You define an extra URL Attribute on your CAT entity:

When you create new instances of CAT, you will have to provide what is the Screen URL for that category (I don't know how you decide that, but for a web application likely you would have to set it to something like "/<your-module>/<your-screen>.aspx" (you can check what's the right URL for each screen from your browser's Location bar).

Then on your Button, you can set its Destination to an ExternalURL (one is defined for you on the Common UI Flow), and pass your CAT.URL as input to it:

  

Solution

Jorge Martins wrote:

You define an extra URL Attribute on your CAT entity:

When you create new instances of CAT, you will have to provide what is the Screen URL for that category (I don't know how you decide that, but for a web application likely you would have to set it to something like "/<your-module>/<your-screen>.aspx" (you can check what's the right URL for each screen from your browser's Location bar).

Then on your Button, you can set its Destination to an ExternalURL (one is defined for you on the Common UI Flow), and pass your CAT.URL as input to it:

  


Thank you so much ~

Solution