Set Global using uri in formula?

In release notes I see:

  • You can now set globals using an URI like kwgt://global/name/values

does this apply to klwp as well?

how can i do this in a flow? i try it with wget and errors -

thanks

Flow has a built-in SetGlobal function in the “Actions” section. You can just use that instead.

You are, of course, correct about that. I really did not phrase the question well. Let me try again…

In general, how/where can I use the uri technique to set a global value? Can I do so in a formula - perhaps as the result of an if() statement by using wget()?

Thanks!

And I should point out that the setGlobal function within flows requires that the global name be known/selected at the time the flow is created. I was actually trying to do something more dynamic - whereby the name was determined at run time.

I also wonder if this is useful ONLY for top-level defined globals or if globals down in komponents could be changed via uri as well?

Thanks

Yes the uri will work with KLWP.
The format is klwp://global/name/value

There are 2 ways to use this.

  1. To use it in a flow, you must use the Intent URI action.

  2. You can also use it with a regular touch action

  • Add a “Open Link” action to any element and in the uri field use the above mentioned uri.
1 Like

Thanks for clarifying all this. I will be working out a way to try this out soon.

I have read about globals being able to be placed in folders and have not tried that yet either. Do you know if these intent actions support that and, if so, how it changes the format you specified?

Also, any idea if these can be used inside of komponents to modify komponent-level globals? I suspect NOT but I am interested in knowing as I try to keep each of my complex wallpaper items as a module.

To use the uri dynamically in a flow, try this

  1. Add a “formula” action and use it to run your logic. It should return a string (the name of the variable)
  2. Add a “Intent URI” action and use this klwp://global/$#last$/value

Yes, thanks. I do get that. It is a powerful addition to the Flow’s dedicated, set global action.

As far as i have tested, it is currently not possible to modify the komponent-level global directly.
But as a work around you can link a global to the komponent-global and pass the values to the komponent.

No this is the first time i am hearing about such a concept. It is really interesting. I would also like to know more about this. Could you point me to the source?

As I said, I am no expert (haven’t even tried this yet). But when you add a global and choose the type, one of them is “Folder” (another I have yet to try is “Secret”). Create that and you get an entry with a Folder icon. Tap that to go “inside” the folder" and you can add globals there. It appears we can put folders inside of folders. Not sure if a folder is a new namespace (ie, can you have globals in different folders with the same name?) or if it is just a way to organize globals to keep the lists of globals small.

Perhaps the folder name is part of the global name used in the intent? If so, not sure what is the delimiter.

I did some testing. Even though any global can be accessed as $gv(FolderName/GlobalName)$ when i use it in the uri like this klwp://global/FolderName/GlobalName/value it breaks.

@frank could you kindly help us out.

This is by design, this is an URL and the slash is part of the name of the global so it won’t work as a path, to access a global within a folder with this:

klwp://global/FolderName%2FGlobalName/value

So replace / with its escape char %2F

This said i will now see if i can fix it because i do not see this as a potential issue

As of now you cannot change a komponent global using an URL unless you do as @nfragment suggested so link the komp global to the root global and change that instead. The only fix would be to add a param to the uri to identify the komponent like:

klwp://global/name/value?module={ID}

Unfortunately right now IDs are stripped on export so this would need a major refactoring on my side

Interesting and kind of confirms my own, but different, test.

What I did was - inside a komponent, - create a top-level global called Test, then create a folder, then create a global inside the folder called Test (interestingly there was no error implying that the folder creates a new namespace for variable names), then created a flow with a set global variable step in it. I then looked at the list of global variable names offered at that point. I expected to find two called Test - with perhaps one containing the folder name as well as the variable name. What I found was that there was only a single Test in the list.

What this implies to me is that the folders are simply for grouping global variables to help make lists smaller and do NOT appears to create a new namespace.

So this remains a bit confused in my mind… Right now, I will just avoid folders.

1 Like

Thanks, as always, Frank. I am constantly amazed at all I can do with KLWP. I love that there is now a way to set a global (via a computed name) from a Flow. It enables a dynamism that was previously desired but not available in any form. I have to balance that with a desire to encapsulate. So if at some point this can be done, it will only make things cleaner/better.

Cheers!

1 Like

This topic was automatically closed 25 days after the last reply. New replies are no longer allowed.