简体   繁体   English

从SharePoint 2010中列表项上的自定义按钮/操作启动工作流(全部使用Visual Studio 2010)

[英]Start a workflow from a custom button/action on a list item in SharePoint 2010 (all with Visual Studio 2010)

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: 这是一个通用列表,这意味着我的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>

Hope it is clear what my XML-Post means. 希望我的XML-Post意味着什么。 Okay, that works fine if I put CommandAction="javascript:alert('should start a workflow');" 好的,如果我将CommandAction =“ javascript:alert('应该启动工作流程');”放上,那很好。 . 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. 有两种类型,一种具有asp的初始化形式,另一种则没有,都对所选项目起作用。 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. 我对SharePoint非常陌生。 So please include in your answer stuff like "Add new ... Empty Element/ JavaScript File" or whatever is neccessary to get what I assume. 因此,请在您的答案中包括“添加新的...空元素/ JavaScript文件”之类的内容,或获得我所假定的内容所必需的内容。

If you have more questions about my workflow design, I will answer asap. 如果您对我的工作流程设计还有其他疑问,我将尽快答复。

Thank you very much, 非常感谢你,

danbruc danbruc

Note: Yes, I just hope that even my Elements.xml is fine. 注意:是的,我只希望我的Elements.xml都可以。 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. 另外,我可以将此选项卡放入ListView的ContextualTab中,但即使是javascript也无法正常工作。

Did you read the documentation on Customizing and Extending the SharePoint 2010 Server Ribbon ? 您是否阅读了有关自定义和扩展SharePoint 2010 Server功能区的文档?

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: 它非常简洁,并向您显示了有关您的问题的要点:您将需要执行回发操作以通过服务器端代码启动工作流程:

<CommandUIHandler Command="WebPartContextualTabs.OnPostback"
CommandAction="javascript:__doPostBack('StartMyWorkflowPostBack','');" />

Now what to put in StartMyWorkflowPostBack to start your workflow? 现在在StartMyWorkflowPostBack放入什么来启动您的工作流程? There are several resources for this and you will find plenty more via Google: 有几种资源可以通过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: 以列表工作流程为例,您将需要像这样启动工作流程:

SPWorkflowProperties.Site.WorkflowManager.StartWorkflow(listItem, associationTemplate, initData);

But as you can see you will need a lot of stuff for this: The SPListItem , the SPWorkflowAssociationTemplate as well as some initiation data. 但是正如您所看到的,您将需要很多东西: SPListItemSPWorkflowAssociationTemplate以及一些初始化数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SharePoint 2010的自定义工作流Visual Studio 2010 - custom workflow visual studio 2010 for SharePoint 2010 使用Visual Studio 2010的SharePoint 2010自定义列表表单 - SharePoint 2010 Custom List Forms Using Visual Studio 2010 在Visual Studio 2010中为Sharepoint 2010合并工作流启动信息路径表单 - Incorporating a workflow Initiation Infopath form in Visual Studio 2010 for Sharepoint 2010 尝试从Windows 7中的Visual Studio 2010部署SharePoint 2010工作流程序包时遇到错误 - Getting error trying to deploy a sharepoint 2010 workflow package from Visual Studio 2010 in Windows 7 在Visual Studio中调试Sharepoint 2010的自定义解决方案 - Debug a custom solution for Sharepoint 2010 in visual studio 特定列表视图的自定义操作-SharePoint 2010 - Custom Action for specific list view - SharePoint 2010 Sharepoint 2010-在生产中部署Visual Studio工作流时出错 - Sharepoint 2010 - Error while deploying visual studio workflow on production 无法使用CSOM启动List Sharepoint 2010 Platform工作流程 - Not able to start List Sharepoint 2010 Platform workflow using CSOM 从Visual Studio 2010位置进行SharePoint部署 - SharePoint Deployment from Visual Studio 2010 Location SharePoint 2010删除列表项中的已完成工作流历史记录 - SharePoint 2010 Delete Completed Workflow History In List Item
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM