If no longer working properly?

My if statements from an older version of shortcuts would have things like:

"If contains " but now i only have “has any content” or “has no content”. Is this expected?

For example:

I worked around it by putting the dictionary value into a text block but that seems very wonky

I am having exactly the same problem. I am trying to use an if statement to manage flow based on a dictionary value stored as a number. I am only getting the exists or doesn’t exist options when I want to determine if the value exceeds zero. Very frustrating and this does not seem to be expected behavior.

Try changing the type of the variable. That can change the selection of the conditions.

What version of iOS are you on? I noticed wonky behavior with dictionaries. I am on 13.2 public beta.

I am using 13.1.2. My dictionary has several entries, some are strings and some are numbers. The number key:value pair is the one not showing all the options under an if statement. I’m not sure how to change the variable type in a dictionary after creating it, but I did make a new number entry in the dictionary and had the same problem in which only has value/doesn’t have value are available under the if statement.

The shortcut doesn’t see into the dictionary which is why you type the key. The content of the dictionary key value pairs can be dynamically modified or even inferred.

When the IF comes to reference the key value pair, it doesn’t know what type of data it is supposed to be. As a result it has the most limited of checks.

When you first pull the value into a particular data type such as a text action or number action, you are effectively casting the data into a particular data type and at that point Shortcuts is able to assign a wider range of conditions to check for.

From a technical perspective, this is good. From a practical perspective, the option to specify the data type on the retrieval of the value would remove the need for the additional ‘casting’ step.

1 Like

Except in the get value from dictionary we do actually say what the type is. So this casting into text is redundant.

Tap the Dictionary Value magic variable that’s on the If action. In there, tap the link/buttons that says as Text. Then keep it as Text and tap Done. You should get more conditions in your If action.

In the get Vale from dictionary, I see these options:

foo is just the key name and so is just text entry.

None of these define the retrieves value as being text. Where are you seeing an option to set the type as text on this action?

Woah. That worked. So it’s not actually picking up it’s default selection?

Okay so you are using it on an individual item within an individual dictionary item rather than the dictionary example from your original screenshot. I think my point still stands :man_shrugging:t2:

I deleted that first example but I think in the if if you tap as text for the dictionary value and keep it as text as supermamon said, it works.

Ahh, in the magic variable “dictionary value” that is the result of that action.