Perspective Dashboard component widgets save during session(Runtime)

Hello, everyone. I hope you are all doing well. I want to add widgets to the dashboard component during a perspective session (runtime) and keep the widgets added for the next session. Anybody who knows about this, please give me some guidance.

The only thing that changes should be the props.widgets.
So you would have to save the props.widgets in a db (based on user). And load those back in there.
As json seems easiest to do using the system.util.jsonEncode and jsonDecode

Hi, I wanted to deal with this by having property change script on widgets property. My code looks like this:

	conf = system.util.jsonEncode(currentValue.value)
	
	system.db.runNamedQuery(
		"App/Configuration/Save Config", 
		{
			"type": "dashboard_widgets",
			"user": self.session.props.auth.user.id,
			"value": conf
		}
	)

The value in the db looks like this:

[{"value":{"isConfigurable":{"value":false,"quality":{"code":0},"timestamp":"May 26, 2022, 4:06:52 PM"},"name":{"value":"My Score","quality":{"code":0},"timestamp":"May 26, 2022, 4:06:52 PM"},"header":{"value":{"style":{"value":{"classes":{"value":"","quality":{"code":0},"timestamp":"May 26, 2022, 4:06:52 PM"}},"quality":{"code":0},"timestamp":"May 26, 2022, 4:06:52 PM"},"title":{"value":"","quality":{"code":0},"timestamp":"May 26, 2022, 4:06:52 PM"},"enabled":{"value":false,"quality":{"code":0},"timestamp":"May 26, 2022, 4:06:52 PM"}},"quality":{"code":0},"timestamp":"May 26, 2022, 4:06:52 PM"},"minSize":{"value":{"columnSpan":{"value":1,"quality":{"code":0},"timestamp":"May 26, 2022, 4:06:52 PM"},"rowSpan":{"value":1,"quality":{"code":0},"timestamp":"May 26, 2022, 4:06:52 PM"}},"quality":{"code":0},"timestamp":"May 26, 2022, 4:06:52 PM"},"style":{"value":{"classes":{"value":"","quality":{"code":0},"timestamp":"May 26, 2022, 4:06:52 PM"}},"quality":{"code":0},"timestamp":"May 26, 2022, 4:06:52 PM"},"position":{"value":{"columnEnd":{"value":4,"quality":{"code":0},"timestamp":"May 26, 2022, 4:10:36 PM"},"columnStart":{"value":1,"quality":{"code":0},"timestamp":"May 26, 2022, 4:06:52 PM"},"rowStart":{"value":1,"quality":{"code":0},"timestamp":"May 26, 2022, 4:06:52 PM"},"rowEnd":{"value":3,"quality":{"code":0},"timestamp":"May 26, 2022, 4:06:52 PM"}},"quality":{"code":0},"timestamp":"May 26, 2022, 4:06:52 PM"},"viewParams":{"value":{},"quality":{"code":0},"timestamp":"May 26, 2022, 4:06:48 PM"},"body":{"value":{"style":{"value":{"classes":{"value":"","quality":{"code":0},"timestamp":"May 26, 2022, 4:06:52 PM"}},"quality":{"code":0},"timestamp":"May 26, 2022, 4:06:52 PM"}},"quality":{"code":0},"timestamp":"May 26, 2022, 4:06:52 PM"},"viewPath":{"value":"Modules/Embedded/Dashboard/Personal Score","quality":{"code":0},"timestamp":"May 26, 2022, 4:06:52 PM"}},"quality":{"code":0},"timestamp":"May 26, 2022, 4:06:52 PM"}]

Is there a way to make it right?

Yeah Yes. But You need to decode the data while read by the query

Transform the named query results to script then run the below code

return system.util.jsonDecode(value)

My problem was reading the property. Trick was to read the “widgets” property not the currentValue.value.

What is your requirement, can you explain clearly. If you have any attachement please attach here for reference