| | | Supreme Being
       
Group: Forum Members Last Login: Monday, May 17, 2010 Posts: 20, Visits: 92 |
| | I understand that the workflow expression editor is based on C#, but is there a better definition of what it will accept? I'm attempting to declare a variable in the expression, set that variable value using a substring and then return the value to the script. I thought it would be something as simple as this (assuming a type of system.string): Variable.FirstName.Substring(0,1); But that doesn't work so i tried to create variables first and work with them: string strFirstName = Variable.FirstName; string strFinitial = strFirstName.Substring(0,1); return(strFinitial); No luck, though. I also can't find much documentation on using the editor... Any help is much appreciated. Thanks, -Nate |
| | | | Supreme Being
       
Group: Forum Members Last Login: Wednesday, February 08, 2012 Posts: 17, Visits: 42 |
| | Hi, You can achieve the scenario by using the below code. string Name="Sri";string strFinitial = Name.Substring(0,1);return(strFinitial); Please find the attached document, which contains the screenshot of the same. Thanks, Suman.
csn
|
| | | | Supreme Being
       
Group: Forum Members Last Login: Monday, May 17, 2010 Posts: 20, Visits: 92 |
| Suman,
Thanks. That code did work. I need to take it one step further. I need to use value from another variable to start with.
You had: string Name = "Sri";string strFinitial = Name.Substring(0,1);return(strFinitial);
what I need is:
string Name = Variable.FirstName;string strFinitial = Name.Substring(0,1);return(strFinitial);
When I attempt this, I get an error saying the "Cannot implicitly convert type 'object' to 'string'" My workflow variables are already setup as strings so I'm not sure why it errors.
Essentially, I need to start with a value from one variable and grab the first character to assign to the value of a second variable.
Also, I'm curious how you got to the Output screen (the last step in your Word document)? I've never seen that before.
Thanks, -Nate |
| | | | Forum Newbie
       
Group: Forum Members Last Login: Sunday, December 27, 2009 Posts: 1, Visits: 11 |
| Hi,
You can achieve this by converting the variable to string type.
string Name = Variable.FirstName.ToString(); string strFinitial = Name.Substring(0,1);return(strFinitial);
Regarding the second question, window which is displaying the variable with value is from BAM reports. When you double click on any instance, process execution of the workflow will be shown. If you click on any activity of the execution view, variable information will be shown in that.
Regards,PKumar |
| |
|
|