Brian Collins Posted February 20, 2019 Share Posted February 20, 2019 I've been using the following as a test run for passing calculated values to document properties for later use: https://spotfired.blogspot.com/2015/01/extract-calculatedvalue-to.html html 1. Create a calculated value and put it inside the calcVal tag:"" 2.Create a (hidden) input property control that updates myPropertyControl: "" 3. Optionally add a label property control to make sure the value is transferred Label Property Control myPropertyControl:"" 4. Optionally add a button to manually trigger the javascript that transferred to the "myPropertyControl" Document Property: Transfer The calculated value takes real number column inputs and uses the following expression to spit out another real number. Essentially, it's just interpolating based on a straight line fit. (I realize there's probably an easier way of doing this calculation but I'm literally brand new to scripting) ((Sum([btu Content] * [Ethane]) - (Sum([btu Content]) * Sum([Ethane]) / Count(RowId()))) / (Sum([btu Content] ^ 2) - ((sum([btu Content]) ^ 2) / Count(RowId())))*${TargetBtuContent})+(Sum([Ethane])/Count(RowId()) - ((Sum([btu Content] * [Ethane]) - (Sum([btu Content]) * Sum([Ethane]) / Count(RowId()))) / (Sum([btu Content] ^ 2) - ((sum([btu Content]) ^ 2) / Count(RowId()))))*(Sum([btu Content])/Count(RowId()))) Then there's a button with the following javascript embedded: var oldValue=0 transferValue = function(){ //get value from calcVal spotfire Calculated Value Dyn Item value=$("#calcVal").text().trim() //update input when oldValue changes if(value!=oldValue){ $("#inputPropertyControl input").val(value).blur(); } oldValue=value } //test value manually $("#transferValueBtn").button().bind('click',transferValue) //if button works, then un-comment this line to automatically refresh //setInterval(transferValue,333) //3 times per second As of now, nothing happens when I click the button. Although the instructions I'm attempting to follow don't say anything about assigning script parameters, is that something that needs to be done here Another concern I have is that data types are not consistent but I don't know if there's anything to that. Any help would be greatly appreciated. Link to comment Share on other sites More sharing options...
Shandilya Peddi Posted February 20, 2019 Share Posted February 20, 2019 What version of Spotfire are you trying this on Link to comment Share on other sites More sharing options...
Brian Collins Posted February 20, 2019 Author Share Posted February 20, 2019 Spotfire Analyst 7.12.0 Link to comment Share on other sites More sharing options...
Shandilya Peddi Posted February 20, 2019 Share Posted February 20, 2019 I just test on 7.12 and the script from the link you shared seems to be working as expected. My HTML is as below <pre> <SPAN id="calcVal"><SpotfireControl id="0597c3e59bfd4a2581d2bafb5f401063" /></SPAN> <i>myPropertyControl:</i> <span style="DISPLAY:none" id="inputPropertyControl"><SpotfireControl id="0a656765f23f442e9ba2626e2c4996d6" /></span> <i>myPropertyControl</i>:<SpotfireControl id="6609158083f74bbca954d2b12c7d5d96" /> <span id="transferValueBtn">Transfer</span> </pre> and my JavaScript is var oldValue=0 transferValue = function(){ //get value from calcVal spotfire Calculated Value Dyn Item value=$("#calcVal").text().trim() //update input when oldValue changes if(value!=oldValue){ $("#inputPropertyControl input").val(value).blur(); } oldValue=value } //test value manually $("#transferValueBtn").button().bind('click',transferValue) Can you verify if you have the same. If it is still not working, would it be possible for you to attach a sample analysis Link to comment Share on other sites More sharing options...
Anita Csizmadia Posted February 20, 2019 Share Posted February 20, 2019 Brian - I was able to use this script successfully in 7.11, but can't get it to work in the new 10.1. Instead, I ended up finding this solution -https://www.youtube.com/watchv=81vXShmDyOM - which I actually prefer. Link to comment Share on other sites More sharing options...
Brian Collins Posted February 20, 2019 Author Share Posted February 20, 2019 Your script solved the issue. Thank you very much for your help! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now