Jump to content

How to access a document property value using the Javscript api for Spotfire


Aman Alok

Recommended Posts

I have a requirement wherein I have to store value of a label to a variable. I see that there is a function called getDocumentProperty().But I'm not able to understand its signature listed as: function getDocumentProperty(propertyName, callback); So I want something like below. var value=getDocumentProperty("property_name", callback function); Could somebody provide an example to illustrate(esp. the callback function) Thanks
Link to comment
Share on other sites

So , for example I have a doc property control named " threshold" which is an input field. Once a user inputs an integer , that value should be stored to a variable named "v" (which should be alerted).. So, can I write like below(which is not working) Could you please help set the variable "v" up.

 

var v= doc.getDocumentProperty("threshold",function(Property){                                         value=Property.value;                                         });alert(v);

 

Thanks

Link to comment
Share on other sites

Hi,

I testedthe following code snippet provided by you but it returns "undefined". Looks like the following snippet should be executed after the page has finished loading.Do you feel we have to make use of the method onDocumentReady(callback function) hereIf yes, how Please help.

var v= doc.getDocumentProperty("threshold",function(Property){

v=Property.value;

});

alert(v); //returns "undefined"

Thanks

Link to comment
Share on other sites

Since you mentioned that you want to set the variable only when the user enters a value to the document property, may be you can use the onDocumentPropertyChange() as well. It would be something as below

 

doc.onDocumentPropertyChange("threshold",function (Property) {v=Property.value;} );

https://docs.tibco.com/pub/spotfire_server/7.5.0/doc/api/TIB_sfire_server_Web_Player_JavaScript_API_Reference/html/M_spotfire_webPlayer_Document_onDocumentPropertyChanged.htm

 If you want to use the onDocumentReady(), then the sample JS would be as below,

doc.onDocumentReady( function{var v= doc.getDocumentProperty("threshold",function(Property){                                         v=Property.value;                                        });});

https://docs.tibco.com/pub/spotfire_server/7.5.0/doc/api/TIB_sfire_server_Web_Player_JavaScript_API_Reference/html/M_spotfire_webPlayer_Document_onDocumentReady.htmhttps://community.spotfire.com/wiki/tibco-spotfire-javascript-api-overview

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...