siri shortcuts - get key of selected dictionary value - sirishortcuts

I have this json format of an array:
{"key_0":"myValue_0","key_1":"myValue_1"}
With this I created a dictionary, which shows me the results like this:
Now I would like to know the key of of the selected dictionary entry.
But I have only this options:
Get:
value
all keys
all values
Any idea?

Here is how to get a key from a dictionary:
Dictionary {'gredgdsg':'fgdsdfg', 'afgfds':12313}
Get [Item] from (Dictionary:Keys)
The way this works is, when you set the Dictionary method to 'Keys', it returns it as a list. So, from there, you can use a Get Item from List block to choose a key.
Hers an image example:
you will have to click this link to view

Related

Table Extraction in UIPath if table has images

I am trying to extract the Table which has the following format
When I want to extract i should have either put some character on place up icon or i dont want that either the case is fine..
But UIPath brings this way.. 78,59,237806 all as one text which is misleading.. How to resolve this issue..
Thanks
Take a look at the Find Children activity. You can specify an item via selector (the table) and use Find Children to return a collection of type UiElement.
So set the filter to extract the "<webctrl tag='tr' />" which will effectively give you a collection of the rows.
Use a For Each to iterate through each UiElement you got from the first Find Children activity, and use that element to run another Find Children. In this case, set the filter to extract the elements with a class of "mid-wrap". This gives you a collection of the elements in the row which match that requirement, and this will exclude the data-up value, since that's a different class.
You can then loop over this collection to get the innertext attribute, which will give you the actual values you're looking for each cell in the row. Use something like Add Data Row to add the values to a datatable, and let the For Each run over the next row in the collection.

How to add rows to an Excel table inside a loop after the columns are mapped?

How to add rows to an Excel table inside a loop after the columns are mapped?
I tried the "Add rows to an Excel table" step, but I can't grab the values from Column1 and Column2 on the "Select" step above.
This should be easy, I guess, but I can't make it.
Thank you,
Your "Select" actions looks like it might be missing something, seems like it will add the whole item to "Column1" and duplicate that for "Column2". If your value is an array but it is not being recognized as so, you can use the "Parse JSON" action, or the json() expression you should be able to select the keys that you want to use for each column.
I might need more details to see the exact issue with your flow, but in the meantime try this:
Parse JSON action
Here the "Initialize variable" will be your blob storage result.
In the Parse JSON, add you blob storage value
In the "Select" action use the body output of the "Parse JSON" action
You should be able to select the specific values you want in your columns
json() expression
The parameter will be your blob storage. In my example is my string variable sown in the image.
Since the "Select" action returns an array as a result, the next step you should use is the "Apply to each" action
The new values mapped in the "Select" action should be available to be used here, if for any reason they are not (it is common for power automate to have issues like this) you can use an expression to get the value
items('Apply_to_each')?['columnName']
Note that the "Apply_to_each" inside "items" will be different if you rename this action.
Then, you'll have your Excel file with all the rows added to the table you selected.

Get changes for an item or a file (properties only)

How can I loop thru all changed columns in a sharepoint list.
I use the
TRIGGER "When a item or file is modified" and then the
ACTION "Get changes for an item or a file (properties only)"
I thought I can loop thru the dynamic content "Column has changed" (A Collection showing which columns have changed)
But this is not a list of changed columns, this is a Object with all columns in the SP-List an a Status "true" or "false" if it is changed or not.
What I want to do, is to loop thru all changed columns and use SWITCH to define next steps per column.
Unfortunately there is no graceful way to do this as of now. However you can achieve this by keeping a reference of all your columns from SharePoint list.
Initialise an array variable ColumnNames and fill all your column names from SP list as it's input. I am taking top 4 columns from your setup. ID, Title, Ticketno, Service_Type
Initialise 2nd Array variable ChangedColumns to collect your changed column names. See the first image below.
Now use a for loop and iterate over ColumnNames and put a condition to check if current item (which will be the column name) value is true or not. If that's true then add it to ChangedColumns array, which we initialised to collect changed column names. The expression you need to use in condition is written as comments in the image itself.

Adding values from TinyDB

So I have a TinyDB with time as a tag and data from Bluetooth as a value,
I want to find a way to sum all the values and store as a variable.
A possible way to do that is create a empty list and sum each item in that list, but how do I create a list with only values from TinyDB and without tags in it?
Here is some code that will add up all the values in a database.
It uses a for each item block with the get tags block.
Inside that loop, it adds the value of the tag to the sum.

get inserted key in redis

I am using this code:
sadd my_set "el1"
to insert "el1" into my_set. sadd only returns the number of inserted elements. What I need is the key of the inserted element so I can retrieve it later. I am sure there is a way that I am not aware of. Is sadd the right function or I should choose something else like set/get?
EDIT: I need something like auto_increment key in mysql. When I insert something, get the last inserted element for further use.
I need something like this:
key: 1
value: {"name": "jack", "tel": "12412415"}
so I could get the array using key = 1.
To do something vaguely similar to "auto_increment," I would look at the INCR function:
http://redis.io/commands/incr
It will increment a value, returning the new value to you - and it is atomic (like most/all Redis commands), so you don't need to worry about threading issues. So your steps would be something like:
SET an increment key.
When you want to add a value, INCR the key, and SET your new value using the value INCR returned.
INCR has at this point increased the value of the increment key, so any repeated value insertions will use the "next" number.
If you want to store a list of items which can be looked up by index, you probably want to do something like this (in programming pseudocode):
// When you initialize your database for the first time.
SET index "0"
// When you want to insert a new item:
INCR index
SET myList:(index value) "My Value"
// When you want to retrieve an item, and you have the index for it:
GET myList:(index value)
In this example, I'm assuming that in your program you are keeping track of the values returned by INCR. The value INCR returns is going to be the index at which you insert the new item, as well as the index with which you'll look up your item later. So, in my example code, replace (index value) with the stored value you got back from INCR (how you do this depends on what programming language you're using, of course).
Note that this DOES allow deletion of items in the middle, via DEL myList:(index value), because you're tracking the last index with index, so even if an item is deleted, the last index will still remain the same - this behaves very similarly to "auto increment" fields in most SQL servers.
You really don't want to use sets for this; sets are inherently unordered, and they are not really made to look things up by "key" - items in a set don't even really have a key. Sets are more useful for the other set operations you can perform on them, like SINTER or SDIFF.

Resources