很抱歉问了一个双重问题,但我对找不到解决方案感到迷惑-或对答案的理解不足。
我的问题就像描述的那样:
我有一些带有按钮的自定义自定义功能区。而且,如果我单击设计按钮,我希望启动工作流程。
好的,有关设置的更多信息:
这是一个通用列表,这意味着我的elemets.xml如下所示:
<CustomAction
Id="MyCustomRibbonTab"
Location="CommandUI.Ribbon.ListView"
RegistrationId="100"
RegistrationType="List">
<CommandUIExtension>
<CommandUIDefintions>
<CommandUIDefinition
Location="Ribbon.Tabs._children">
<Tab Id="Ribbon.CustomTab" Sequence="501">
... (Scaling)
<Groups Id="Ribbon.CustomTab.Groups">
<Group
Id="Ribbon.CustomTab.GroupOne"
Sequence="52">
<Controls Id="Ribbon.CustomTab.GroupOne.Controls">
<Button
Id="Ribbon.CustomTab.GroupOne.ButtonOne"
Command="CustomTab.ButtonOneCommand"
Sequence="11">
</Controls>
</Group>
</Groups>
</Tab>
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler
Command="CustomTab.ButtonOneCommand"
CommandAction="javascript:alert('how start workflow here?');" />
/>
</CommandUIHandlers>
</CommandUIExtension>
<!-- what about starting workflow here? How? -->
</CustomAction>
希望我的XML-Post意味着什么很清楚。好吧,如果我将CommandAction =“ javascript:alert('应该启动工作流程');”放上,那很好。 。我的意思是,此警报会弹出,我可以单击“确定”,仅此而已。
现在,我在同一项目中设计了我的工作流程。有两种类型,一种具有asp的初始化形式,另一种则没有,都对所选项目起作用。我可以在使用标准功能区“工作流”时启动它们,然后单击它们。到目前为止一切都很好。
但是我想通过单击我的按钮来启动每个工作流程,而不是像现在这样点击更多。到目前为止,谢谢您对我的帮助。
我对SharePoint非常陌生。因此,请在您的答案中包括“添加新的...空元素/ JavaScript文件”之类的内容,或获得我所假定的内容所必需的内容。
如果您对我的工作流程设计还有其他疑问,我将尽快答复。
非常感谢你,
丹布鲁克
注意:是的,我只希望我的Elements.xml都可以。我从网络上拿走了所有东西。因此,如果您有重新设计的建议,我会开放的。只是看不见解决方案。
此外,我可以将此选项卡放入ListView的ContextualTab中,但即使是javascript也无法正常工作。
最佳答案
您是否阅读过Customizing and Extending the SharePoint 2010 Server Ribbon上的文档?
它非常简洁,向您显示了有关您的问题的重要要点:
您将需要执行回发操作以通过服务器端代码启动工作流程:
<CommandUIHandler Command="WebPartContextualTabs.OnPostback"
CommandAction="javascript:__doPostBack('StartMyWorkflowPostBack','');" />
现在在
StartMyWorkflowPostBack
中添加什么来启动您的工作流程?有几种资源可以通过Google找到更多资源:Start Workflow From c# Code
Creating new instance of SharePoint workflow through C# code.
HOWTO: Start a SharePoint 2010 Workflow Programatically
让我简短地解释一下:您没有告诉我们哪种工作流程。基于列表的工作流或网站工作流的启动方法有所不同。以列表工作流程为例,您将需要像这样启动工作流程:
SPWorkflowProperties.Site.WorkflowManager.StartWorkflow(listItem, associationTemplate, initData);
但是正如您所看到的,您将需要很多东西:
SPListItem
,SPWorkflowAssociationTemplate
以及一些初始化数据。关于sharepoint - 从SharePoint 2010中列表项上的自定义按钮/操作启动工作流(全部使用Visual Studio 2010),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8603554/