- Register a Data Function
Edit > Data Function Properties > [Register New]
Name: copyCutomExpressionToDocPropViaDataFunction
Type:TERRR
Script: y<-x
Input Parameters > [Add]
Input parameter name: x
type: Value
allowed data types: [all]
Output Parameters > [Add]
Result parameter name: y type: Value - [Run] to Edit Parameters
Name: currentTime
Refresh function automatically:[x]yes [ ]no
Run Location: Force Local
input > x > input handler > Expression
Expression: DateTimeNow()
Output > y > Output Handler > Document Property > [New]: yourDocProp - Attach your Action Script when yourDocProp changes.
Method 2:
Basically you change the page navigation to history arrows showing an 'agreement or welcome' page with an OK button that triggers your start-up script. Last line switches back to tabs or step by step page navigation mode.
# change manually the page navigation mode to 'history arrows' to force user to click on the agree button
# --------------------------------------------------------
# your start up script goes here
# Example of a startup script:
# Requirement is to set row level security with embedded data, so
# personalized info links are not an option.
# We could get username from the system and store it on a document property
# and use the document property to limit the data by user
from System import Environment
Document.Properties['currentUser'] = Environment.UserName
# To limit the data by user on your visualization, we use a custom exprssion like this: '${currentUser}' = [user]
# The previous step could be scripted, but it is out of the scope of this post, so data limiting on a visualization by user is done manually for now
# Last step will be to move to the page of your choice and switch back to tabs
# --------------------------------------------------------
Document.Pages.NavigationMode = Document.Pages.NavigationMode.Tabs
7 comments:
Do you have any example of how to do data limiting on a visualization inside Python script instead of manually? I'd really appreciate that!
Hello Anna, There are couple of ways,
1) Set the filters programatically: http://spotfired.blogspot.com/2014/03/change-filters-programatically.html --or-- http://spotfired.blogspot.com/search?q=filter
2) Manipulate the underlying data programatically
3) Create a custom expression in your visualization>properties>limit data using custom expression. There, you can also use property control valuesl.
If you send me your specific requirements, I can probably help you.
Jose, thank you for the solutions you mentioned. I am mostly interested in number 2 - how to manipulate the underlying data programatically. If you could share some example, that would be great! I'm just thinking what solution to choose and I need to learn of all possible ways to do it.
I guess I've found what I was looking for - WhereClauseExpression:
from Spotfire.Dxp.Application.Visuals import VisualContent
vc = vis.As[VisualContent]()
vc.Data.WhereClauseExpression = "[ColumnXXX] = 2"
Source: http://stn.spotfire.com/spotfire_client_help/text/text_action_script_examples.htm
Thanks for sharing Anna!
Hi Jose,
do you know a way how the switch to another tab AND execute a script when the user clicks on an action control? I'm afraid only one of them is possible at a time?
Cheers
Christian
To execute a script at startup and when toggling tabs, I used a hidden button and $(document).ready(function());, but toggling tabs doesn't seem to work anymore in the 6.5 client. It works in the web player though.
$(function () {
function executeScript() {
$('#hiddenBtn input').click();
//or- document.getElementById('hiddenBtn').childNodes[0].click();
}
$(document).ready(function(){executeScript()});
});
Post a Comment