Shubh M Posted July 23, 2019 Share Posted July 23, 2019 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 More sharing options...
David Boot-Olazabal Posted July 23, 2019 Share Posted July 23, 2019 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 More sharing options...
Shubh M Posted July 25, 2019 Author Share Posted July 25, 2019 Thanks a lot David, Document Property helped for now :) I will let you know if i run into any issues after this point. thanks again 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