Hey,
I used to be able to do something similar waaay back on an earlier version of UD with the Sync-UDElement function, but i’m struggling currently on 4.0.9 trying to work this one out.
Right now I’ve got a new-uddynamic on my home page:
I’m trying to work out how I can trigger this from an API endpoint or script.
I’ve tried using Sync-UDElement but it doesnt have the -integrated flag (this is the way I used to do it before but back when it was only app tokens).
Using Sync-UDElement -Id "TestDynamic" -Broadcast throws: [error] You cannot call a method on a null-valued expression.
Okay I figured out how to get it working, but not sure if this is a bug or not.
My script was running on the same custom environment as my App where the component is, when i changed the script to run on the integrated environment instead, this started working.
Seem to have difficulty getting Set-PSUCache to work too.
Let me give a litte more context to what I’m trying to acheive here.
Basically I have a nightly web app restart at 2am.
I doubt i’ll many users visiting at this time, but just in case I was thinking of putting new-uddynamic at the top of all my pages which contains an if statement, based on a cache variable, it triggers a toast or modal or something advising the site will go offline for maintenance in 5 - 10mins or something to that effect.
My initial thought before cache got involved was just to have an empty new-uddynamic that i could just set the content of and trigger, but set-uddynamic cant be done from an api/script from what I can tell?
[error] Parameter set cannot be resolved using the specified named parameters. One or more parameters issued cannot be used together or an insufficient number of parameters were provided.
I’ve also noticed another thing here, whenever I update a variable’s value in PSU (either by gui or command) any configured Apps/dashboards restart and show as ‘Deploying’, which is not ideal.
$Cache and Set-PSUCache are actually different caches.
You need to use Get-PSUCache to get the value set by Set-PSUCache. As I’m typing this, it makes me realize this is weird and we should probably improve it.
The variables resetting apps is by design as we set the variables when the app starts. That said, this should also be improved and has been on my list for awhile. You can avoid this by turning off auto-deploy on any app you dont want this to happen.
I’ll have to look at sync-psucomponent. At first glance, it seems like all this should be implemented properly but I need to test.
Thanks man! This is all in it’s infancy so we’re just using it internally at the moment so there’s no real rush or impact from these things (not to mention I’m leaving the org in a week anyway). Appreciate the tip on auto deploy!
I’ll be continuing my work on my personal instance in the mean time and hope to introduce PSU in the new org I join too.