Michael Herman - Parallelspace

What are the technical details behind what

UsesCurrentItem="true"

in an Action in an ACTIONS file e.g. Set Field in Current Item in WSS.ACTIONS

What does this do   What does this cause to happen   How do I use it in my custom SPD WF activity




Re: SharePoint - Workflow What does UsesCurrentItem="true" in an Action in an ACTIONS file do?

Michael Herman - Parallelspace

In the MS WSS.ACTIONS file, UsesCurrentItem="true" only appears when the activity expects __Context, __ListId and __ListItem to be set as In parameters (see below for a sample from WSS.ACTIONS).

Is this what UsesCurrentItem="true" is supposed to do ....does it do anything else

Cheers,
Michael.

--------------------------------------

<Action Name="Set Field in Current Item"
ClassName="Microsoft.SharePoint.WorkflowActions.SetFieldActivity"
Assembly="Microsoft.SharePoint.WorkflowActions, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
AppliesTo="list"
UsesCurrentItem="true"
Category="Core Actions">
<RuleDesigner Sentence="Set %1 to %2">
<FieldBind Field="FieldName" Text="field" Id="1" DesignerType="writablefieldNames" />
<FieldBind Field="Value" Text="value" Id="2" TypeFrom="FieldName"/>
</RuleDesigner>
<Parameters>
<Parameter Name="FieldName" Type="System.String, mscorlib" Direction="In" />
<Parameter Name="Value" Type="System.Object, mscorlib" Direction="In" />
<Parameter Name="__Context" Type="Microsoft.SharePoint.WorkflowActions.WorkflowContext, Microsoft.SharePoint.WorkflowActions" Direction="In"/>
<Parameter Name="__ListId" Type="System.String, mscorlib" Direction="In" />
<Parameter Name="__ListItem" Type="System.Int32, mscorlib" Direction="In" />
</Parameters>
</Action>






Re: SharePoint - Workflow What does UsesCurrentItem="true" in an Action in an ACTIONS file do?

Anonymous

creating a custom workflow activity in VS2005 and then using it in SharePoint Designer. I'm trying to reference the current list item by declaring the __ListItem and __ListId Dependency Properties in my custom activity and in the wss.Actions file

I have successfully used the __Context property, but can't seem to get the other __ListItem and __ListId ones to work. I get a "Error Occurred" message in the workflow history of the list item when viewing the item in SharePoint. I think it¡¯s a compilation error but there are no detailed messages to tell me for sure.

If referenced this thread, but the problem has not been resolved.

I'm not referencing the properties yet, just declaring them. Here are the declarations in my custom activity followed by the wss.actions file:


#region DepedencyProperties for the Activity

public static DependencyProperty __ContextProperty = DependencyProperty.Register("__Context", typeof(WorkflowContext), typeof(EmailWithSelectedSender));

public static DependencyProperty __ListIdProperty = DependencyProperty.Register("__ListId", typeof(string), typeof(EmailWithSelectedSender));

public static DependencyProperty __ListItemProperty = DependencyProperty.Register("__ListItem", typeof(int), typeof(EmailWithSelectedSender));

#endregion

#region Properties

//other property declarations excluded for clarity

[ValidationOption(ValidationOption.Required)]

public string __ListId

{

get { return (string)GetValue(__ListIdProperty); }

set { SetValue(__ListIdProperty, value); }

}

[ValidationOption(ValidationOption.Required)]

public int __ListItem

{

get { return (int)GetValue(__ListItemProperty); }

set { SetValue(__ListItemProperty, value); }

}

[ValidationOption(ValidationOption.Required)]

[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]

public WorkflowContext __Context

{

get

{

return (WorkflowContext)base.GetValue(__ContextProperty);

}

set

{

base.SetValue(__ContextProperty, value);

}

}

----------------------------- Start of WSS.ACTIONS file (abbreviated) -----------------------------------------------------

<Action Name="Email With Selected Sender"

ClassName="ACSC.SharePoint.WorkFlow.ActivityLibrary.EmailWithSelectedSender"

Assembly="ACSC.SharePoint.WorkFlow.ActivityLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=83dfca4e0ff4e852"

AppliesTo="all"

Category="Sample" UsesCurrentItem="true">

<RuleDesigner Sentence="Send %1 from %2 using %3">

<FieldBind Field="To,CC,Subject,Body" Text="this message" DesignerType="Email" Id="1"/>

<FieldBind Field="FromEmailAddress" Text="this login" Id="2" DesignerType="TextArea"/>

<FieldBind Field="NotificationTemplate" Text="email template" Id="3" DesignerType="TextArea"/>

</RuleDesigner>

<Parameters>

<Parameter Name="__Context" Type="Microsoft.SharePoint.WorkflowActions.WorkflowContext, Microsoft.SharePoint.WorkflowActions" />

<Parameter Name="__ListId" Type="System.String, mscorlib" Direction="In" />

<Parameter Name="__ListItem" Type="System.Int32, mscorlib" Direction="In" />

<Parameter Name="To" Type="System.Collections.ArrayList, mscorlib" Direction="In" />

<Parameter Name="CC" Type="System.Collections.ArrayList, mscorlib" Direction="Optional" />

<Parameter Name="Subject" Type="System.String, mscorlib" Direction="In" />

<Parameter Name="Body" Type="System.String, mscorlib" Direction="Optional" />

<Parameter Name="FromEmailAddress" Type="System.String, mscorlib" Direction="In" />

<Parameter Name="NotificationTemplate" Type="System.String, mscorlib" Direction="In" />

</Parameters>

</Action>

----------------------------- End of WSS.ACTIONS file --------------------------------------------------------------------


Any suggestions would be great.

Thanks in advance, Brook





Re: SharePoint - Workflow What does UsesCurrentItem="true" in an Action in an ACTIONS file do?

Michael Herman - Parallelspace

Brook,

I've only taken a very quick look at your posting...

1. Don't add your acction to WSS.ACTIONS. Create your own BROOK.ACTIONS and leave in the same folder as WSS.ACTIONS. WSS and SPD will automatically pick it up.

2. In terms of UsesCurrentItem, __Listd and __ListItem, everything appears correct on first glance.

3. You must have signed and GAC'ed your assembly because you mention __Context is working.

I don't have anything more specific to suggest. Have you looked at http://www.ideseg.com/AddCustomWorkflowActivitiesToSharePointDesignerPart1.aspx

My guess is the problem is else where in your activity.

Michael.






Re: SharePoint - Workflow What does UsesCurrentItem="true" in an Action in an ACTIONS file do?

Anonymous

Hi Michael,

Thanks for the feedback. I can now compile.

However, I'm having trouble getting the values from the __ListId and __ListItem values. I get a blank for ListId and a "0" for __ListItem.

How do I get a reference to the current item

I need to use its values to fill an email template and send out a notification.

I'm using the UsesCurrentItem="true" attribute in the Action's tag.

Thanks in advance, Brook





Re: SharePoint - Workflow What does UsesCurrentItem="true" in an Action in an ACTIONS file do?

Anonymous

Hi,

Fixed it.

I had to add the __ListId and __ListItem properties back to the .Actions file Smile





Re: SharePoint - Workflow What does UsesCurrentItem="true" in an Action in an ACTIONS file do?

Michael Herman - Parallelspace

I presume you also created your own foo.actions file (see above)

Else you might loose your action the first time you install a WSS service pack.






Re: SharePoint - Workflow What does UsesCurrentItem="true" in an Action in an ACTIONS file do?

Anonymous

Yes I have. Thanks again Michael.





Re: SharePoint - Workflow What does UsesCurrentItem="true" in an Action in an ACTIONS file do?

turon850

I'm still trying with WSS3.0 and can't get the __ListItem and the __ListId values in the Activity.

Do you use MOSS or WSS3.0





Re: SharePoint - Workflow What does UsesCurrentItem="true" in an Action in an ACTIONS file do?

Michael Herman - Parallelspace

It shouldn't matter.

Start from scratch with a simple example like: http://www.ideseg.com/AddCustomWorkflowActivitiesToSharePointDesignerPart1.aspx

Michael.