Custom widget and Application Data

I want to get value in custom widget from application variable x = 5; how can we acheive data in custom widget.This can resolve to solve multiple question;
If I have var x = 5 in application and want to console.log in custom widget and my expectation is to be get value in console.log in custom widget kindly resolve ASAP.

Hi @avinash.kumar

please read the last post in this Thread, where you already posted the same question:

Calling a connector function from within a custom widget? - Custom Widgets - Tulip Community

You can also use console.log(outputVal); however this is no output to your TULIP Application but to your Browser Console (is this what you want? what is the use case?).

For custom Widget basics (input and output handling) also read: Custom Widgets Overview (tulip.co)

@thorsten.langner Please try to understand my question
I have JSON Data in connector and I want to set value in props so that I can console the value or get the JSON Data in Custom Widgets?

Hi @avinash.kumar,

what I still don’t get is the point of the console. Do you really want to throw the value in the console, or do you want to output values into the app or use them to achieve functionality of the widget?

However, the use case is key. There are several ways to get connector output values into the widget.
JSON is only text, So you could simply put the whole JSON in one text variable, and push it into a prop of a custom widget.
Then you can do whatever you want with the JSON using Javascript.

More common would be to output the Object Variable in the HTTP connector and use this variable as prop in the widget.

Where exactly is your point you are stuck? What did you try? Do you get error messages? What is the exact target?

So I still suggest reading the Knowledge base on HTTP connectors and Custom Widgets.
Then precise your question. It is very generally formulated so it is hard to figure out your exact problem.


edit:
your question was to put a value of x=5 from the application to console.log in custom widget.

I exactly answered the question in the linked post:

image

The only difference was, I used -12 instead of 5 and I output the value * 2 instead of directly…

Did you try this? where did you stuck or got unexpected results?

JSON is only text, So you could simply put the whole JSON in one text variable, and push it into a prop of a custom widget.

my question is how can we push data in prop??


As I have taken variable of JSON Data in re
Now what to do in custom widget so that can get the value. I dont need API call to get the data we need var re= in custom widget

I hope now you understand every things

You need to use your custom widget in the app, not the variable.

There the widget has properties, where you can attach your variable.

It’s a bit unhandy to discuss that in two threads… I answered this question in the other thread already (including screenshot).