Jump to content
We've recently updated our Privacy Statement, available here. ×

How to fetch Login username and store the same in Calculated Column


Shubh M

Recommended Posts

Folks

I need to retrieve the login username and then store it in calculated column. I looked into mnay forums and found some content. and wrote a script like below.

But the same is giving me some error. I am new to Python and Spotfire Scripting, so not sure where is the problem.

*************************

from Spotfire.Dxp.Data import CalculatedColumn

from System import Environment

newColName= "UserInfo"

calc = Environment.UserName

print calc

cc1= Document.Data.Tables["my_table"].Columns.AddCalculatedColumn(newColName,calc).As[CalculatedColumn]()

*******************

The above code works fine and prints the username value till the print statement. But then throws error while storing in calculcated column.

Any leads to this will be greatly appreciated. Thanks

 

Regards

Shubs

Link to comment
Share on other sites

Hi Shub,

 

I think you need to place the calc value in a document property first. Once you have that, you should be able to create a calculated column in which you 'call' this document property (via the custom expression window).

Your code should be pretty much similar as you now have (the line calc = Environment.UserName can be replaced with something like this calc = Document.Properties["YourDocProp"]). You have to create this YourDocProp first of course :-). And then call upon this document property when you create your calculated column.

Kind regards,

David Boot-Olazabal

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...