从 SharePoint 2010 中列表项上的自定义按钮/操作启动工作流(全部使用 Visual Studio 2010)
我很抱歉问了一个双重问题,但我找不到解决方案,或者对答案缺乏理解,这让我很困惑。
我的问题就像所描述的那样:
我有一些自制的带有按钮的自定义丝带。如果我单击设计的按钮,我喜欢启动工作流程。
好的,更多关于设置的信息:
它是一个通用列表,意味着我的 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('should start aworkflow');" ,效果就很好。 。我的意思是,弹出此警报,我可以单击“确定”,仅此而已。
现在我在同一个项目中设计了我的工作流程。有两种类型,一种是带有asp启动形式的,一种是没有的,都是对选中的项目进行操作。我可以在使用标准功能区“工作流程”时启动它们,然后单击它们。到目前为止一切都很好。
但我想通过单击按钮来启动每个工作流程,而不是像现在那样进行更多单击。谢谢你到目前为止对我的帮助。
我对 SharePoint 非常陌生。因此,请在您的答案中包含“添加新的...空元素/ JavaScript 文件”之类的内容或获得我的假设所需的任何内容。
如果您对我的工作流程设计有更多疑问,我会尽快答复。
非常感谢,
danbruc
注意:是的,我只是希望我的 Elements.xml 没问题。我全部取自网络。因此,如果您有重新设计的建议,我持开放态度。只是盲目地看到解决方案。 此外,我可以将此选项卡放入 ListView 的 ContextualTab 中,但即使 javascript 也无法工作。
I'm sorry for asking a double question, but I'm messed up with finding no solution - or a missing understanding of answers.
My problem is like descrided:
I have some self constructed custom ribbons with buttons. And I like to start a workflow if I click on designed button.
Okay, more about settings:
It is a generic list, means, my elemets.xml looks like that:
<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>
Hope it is clear what my XML-Post means. Okay, that works fine if I put CommandAction="javascript:alert('should start a workflow');" . I mean, this alert pops up and I can click okay, nothing else.
Now I have in same project my workflow designed. There are two types, one with initiation form in asp, the other without, both operating on selected item. I can start them while using the standard ribbon "Workflows" and then click them. Everything is fine so far.
But I want to start each workflow by clicking my button, not having more clicks as it is now. Thank you so far in helping me.
I'm very new on SharePoint. So please include in your answer stuff like "Add new ... Empty Element/ JavaScript File" or whatever is neccessary to get what I assume.
If you have more questions about my workflow design, I will answer asap.
Thank you very much,
danbruc
Note: Yes, I just hope that even my Elements.xml is fine. I took all from web. So if yuo have suggestions to redesign, I am open minded. Just blind in seeing the solution.
Additionally, I'm able to put this Tab inside ContextualTab of ListView, but then even javascript is not working.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否阅读过有关自定义和扩展 SharePoint 2010 Server 功能区的文档?
它非常简洁,并向您展示了有关您的问题的要点:
您将需要进行回发以通过服务器端代码启动工作流程:
现在要在
StartMyWorkflowPostBack
中放入什么来启动工作流程?有多种相关资源,您可以通过 Google 找到更多资源:让我简单解释一下:您没有告诉我们哪种工作流。基于列表的工作流或站点工作流,启动方法有所不同。以列表工作流程为例,您需要像这样启动工作流程:
但正如您所看到的,为此您将需要很多东西:
SPListItem
、SPWorkflowAssociationTemplate
code> 以及一些启动数据。Did you read the documentation on Customizing and Extending the SharePoint 2010 Server Ribbon?
It is very concise and shows you an important points concerning your problem:
You will need to do a postback to initiate the workflow via serverside code:
Now what to put in
StartMyWorkflowPostBack
to start your workflow? There are several resources for this and you will find plenty more via Google:Let me explain in short: You did not tell us what kind of workflow. A list based workflow or a site workflow, start methods differ for these. Taking the list workflow as an example you will need to just start the workflow like so:
But as you can see you will need a lot of stuff for this: The
SPListItem
, theSPWorkflowAssociationTemplate
as well as some initiation data.