Using WF variables in PowerShell activity

Sep 23, 2009 at 3:18 PM

Hi,

How can I use a workflow variable in my powershell activity?

Fo instance, I have a field (Text) that is too long to show on a view, as it renders that view unreadable. So I want to get the first x letters of that field and put them on another field named ShortText.

The problem is that I don't know how to pass the field Text to the script to get the first letters.

Thanks.

Rodrigo.

Sep 23, 2009 at 4:05 PM

Hi,

I tried this to truncate to first 100 letters:

$value = [%ListName:BodyField%]

if ($value.Lenght -gt 100) { %output = $value.substring(0,100) }

else { $output = $value }

 

I got this error:

23-09-2009 11:40 Error
No presence information System Account

Error Executing PowerShell Script. Could not load file or assembly 'System.Management.Automation, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified. Error 23-09-2009 11:40 Error

No presence information System Account

Error Executing PowerShell Script. Requested registry access is not allowed. Error

 

I would appreciate any hint...

Thanks.

 

Coordinator
Sep 25, 2009 at 7:38 AM

Hint 1: install powershell on your server(s)
Hint 2: put [%ListName:BodyField%] in quotes.

Bye, christian

Sep 28, 2009 at 10:10 PM

Hi Christian.

Thanks for your reply.

It works fine unless BodyField contains a quote character itself…

In that case, the WF fails saying there is an unknown token (the first word after de quote).

Are you aware of any method to avoid this?

Items on that list can be created by mail, so it is not a valid solution to have a field validation on NewItem.aspx and EditItem.aspx…

Thanks again.