戰地連結︰ Home My Flickr NBA.com About

2008年5月11日星期日

Update Workflow Task properties with 'UpdateTask Activity'

吹水

OK~ 之前幾個post打左咁多英文, 都係時候講下廣東話啦... :p
話說我今個星期接到單非常好玩既job, 就係無人做過既 WSS/MOSS Workflow 啦~ 個期仲要鬼咁急, 不過只係做demo啫~
由於我係用 Sequential Workflow + Looping  + Create / Update / Delete Tasks, 所以出現好多問題, 最後我用左個折衷方法就係只用一個task, 靠update佢既 "Title" 同 "AssignedTo" properties 黎 "扮" 不同既 tasks. 不過最後我發覺原來要 update 一個 task 既 properties 係幾煩既....

Reference

Task reassignments using UpdateTask Activity

Overview / Steps (用返英文啦)

In order to update the task properties, 'UpdateTask' Activity should be used in VS2005 Workflow Designer. If you cannot find this in the Toolbox, try making a new Tab in Toolbox and then right-click and select "Choose Items...", then add "Microsoft.SharePoint.WorkflowActions.dll".

After 'UpdateTask' Activity is inserted, double click on it in Workflow Designer and use "UpdateTask" class to set new value for the task properties.

Code Snippet:

  113 private void updateTask1_MethodInvoking(object sender, EventArgs e)

  114         {

  115             UpdateTask task = (UpdateTask)sender;

  116             task.TaskProperties.AssignedTo = this.assignee;

  117             task.TaskProperties.Title = "Please update...";

  118         }

In the above snippet, the "AssignedTo" and "Title" properties are updated.

Key Point: Setting "AfterProperties" for "OnTaskChanged" Activity and "TaskProperties" for "UpdateTask" Activity

Very often you will find that using the method state above could not update the task properties, this is because the "OnTaskChanged.AfterProperties" and "UpdateTask.TaskProperties" are both bound to the same "SPWorkflowTaskProperties" object. So make sure that they are NOT bound to the same Properties.

I also found that if you have more that one "OnTaskChanged" Activities and "UpdateTask" Activities for a certain task, you only need two "SPWorkflowTaskProperties" objects. One for all "OnTaskChanged" Activities and the other for all "UpdateTask" Activities.

2008年5月10日星期六

Development/Deployment Steps of Workflow in MOSS 2007 and WSS 3.0

Overview

Both MOSS 2007 & WSS 3.0 supports workflow features. However, the steps in developing and deploying workflow in them are quite different. This is because two different types of Visual Studio Project templates are provided for MOSS 2007 and WSS 3.0 separately.

According to my experience, MOSS 2007 can use both types in development and deployment, yet WSS 3.0 can only use "SharePoint Services Workflow Template" in deployment, using "SharePoint Server Workflow Template" will result in error.

Typical Error:
"System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Office.Workflow.Feature, assembly 'Microsoft.Office.Workflow.Feature"

Development Environment

IDE: Visual Studio 2005 (VSTS)
Others:
MOSS SDK v1.2 (For MOSS 2007)
VS extension for WSS (For WSS 3.0)
VS extension for Workflow

MOSS 2007

Development

  1. In Visual Studio, "New" => "Project"
  2. Expand "Visual C#" section, select "Share Point Server (Sequential / State Machine) Workflow Template"
  3. Develop Workflow, Forms (Association, Initiation, Modification or Task Form), and coding.

Deployment

  1. Setup "feature.xml", "workflow.xml"
  2. Open "PostBuildActions.bat" inside "DeploymentFIles" and modify it according to instructions inside the .bat file.
  3. Right-click on Project Name in "Solution Explorer" and select "Properties"
  4. Select "Build Events" tab, at "Post-build event command line", change parameter UNDEPLOY to DEPLOY
  5. Build / Re-build the project
  6. Done!

WSS 3.0

Development

  1. In Visual Studio, "New" => "Project"
  2. Expand "Visual C#" section, select "Share Point Services (Sequential / State Machine) Workflow Template"
  3. Develop Workflow, Forms (Association, Initiation, Modification or Task Form), and coding.

Deployment

  1. Setup "feature.xml", "workflow.xml"
  2. Open "Install.bat" and modify it according to instructions inside the .bat file.
  3. Build / Re-build the project
  4. In Command Prompt, navigate to your project folder. Run "Install.bat"
  5. Done!

Solution for WSS 3.0 'Microsoft.Office.Workflow.Feature NOT FOUND' Deployment Error

Warning: This is only a small workaround when you develop the whole WSS 3.0 workflow based on MOSS 2007 Project Template and get error in deployment. This is not guarantee to work and the workflow might not run even after it is activated in WSS 3.0. Always use "SharePoint Services Workflow Template" for WSS 3.0 Projects.

To workaround this error is simple, just open the "feature.xml" of your workflow project in Visual Studio and delete the two lines beginning with "ReceiverAssembly=...." and "ReceiverClass=.....". After that, try re-build your project and you're done!

Reference

WSS 3.0 - Microsoft.Office.Workflow.Feature file not found??

2008年5月9日星期五

Accessing Data from Workflow Association and Initiation Forms in Windows SharePoint Services 3.0

Reference 

Accessing Data from Workflow Association and Initiation Forms in Windows SharePoint Services 3.0

Overview

It is often that a Workflow template would need some initial parameters when it is first associated to a document library or started by an event. In SharePoint Products, it is supported by adding Association and Initiation Forms to the Workflow template.

However, WSS 3.0 does not support InfoPath Form Services (I remember only MOSS 2007 Enterprise Edition supports this). We are going to create the Assoc/Init Forms by ASP.NET Forms, and apply the form value into the Workflow instance.

2008年5月8日星期四

WSS 3.0 - "Value does not fall within expected range" after installing Workflow feature

Reference

Deploying a custom MOSS 2007 workflow

Symptoms

After installing "Workflow Feature" (by modifying feature.xml, workflow.xml & install.bat and then run install.bat), Error "Value does not fall within expected range" returned when clicking "Document Library Settings" at ANY Document Libraries.

Results behind

Corrupted feature.xml or workflow.xml (e.g. typing error, Type in wrong "TaskListContentTypeId")

Solution

Run:
stsadm -o deactivatefeature -filename %Path of the feature.xml (e.g. C:\XML\feature.xml)% -url http://%YourServerURL% -force <= to deactive the corrupted feature

stsadm -o uninstallfeature -filename %Path of the feature.xml (e.g. C:\XML\feature.xml)% -force <= to uninstall the corrupted feature

Remarks

This solution should be applicable to MOSS 2007

2008年5月6日星期二

MOSS 2007 BDC - Action

Overview

Action 係 BDC 既一個 feature, 佢既功能係為每一個 record 加上 Custom Link, 而 Link 入面亦可以放入 parameters. 如果配合InfoPath Form / Web Services, 就可以實現用 BDC update / create / delete 既功能.

Reference

MSDN - Action

Sample application definition XML

   90       <Actions>

   91         <Action Position="1" IsOpenedInNewWindow="false" Url="http://localhost/edit.aspx?id={0}" ImageUrl="/_layouts/images/delete.gif" Name="Delete">

   92           <ActionParameters>

   93             <ActionParameter Index="0" Name="Id" />

   94           </ActionParameters>

   95         </Action>

   96       </Actions>


於 Share Point Central Administration 為 Entity 加 Custom Actions

其實除了 definition file, 我們還可以在 Import 了 BDC Application 之後, 在 "Share Point 3.0 Central Administration" Web Page 那裏再加減 Custom Actions. 這樣做的好處不單是可以隨時更改 Actions, 不用每次都改動那個大得恐怖的 XML (之後還要 import...), 而且在 central administrationh 做錯的可能性幾乎是零 (錯了也可輕易改正).

在 "Share Point 3.0 Central Administration" 改 Actions 的 Steps:

  1. 在左邊的 navigation bar 按 "SharedServices"
  2. 在 "Business Data Catalog" Section 按 "View entities"
  3. 選擇想要加 Actions 的 Entity
  4. 在 "View Entity" 版面 scroll 到下面, 在 "Actions" Section 選想要更改的 Action, 或按 "Add Action" 增加 Action.

在 BDC Data List Web Part 裏面 display Actions dropdown list.

要在 Data List 裏面 display Actions dropdown list, 方法是要於 web part 中選好title column. 而選 title column 的方法如下:

  1. 去想要更改的 Web Part Page 選 "Edit Page"
  2. 在想要改的 Web Part 右上角 選 "Edit View"
  3. 在 "Edit View" Page, "Column" Section, 選 Column Name 左邊的 Radio Button 來 set Title Column.

效果如下︰

2008年5月3日星期六

敗家癮之回歸....

星期三同阿強佢地去左圓方Element 睇 Iron Man. 其實我之前已經0向 NBA 度見到佢既廣告, 去左official site 度睇 gallery 都頗為期待. 基本上而家我會入戲院睇既戲, 一係就係大製作大場面+特技, 另外就係我認為值得支持既港產片 (例如 "無當變幻時", "門徒" 同埋 "投名狀"). 而要睇 Iron Man, 當然要入戲院睇啦~

睇完之後覺得絕對值回票價, 特技交足功課 (我覺得逼真過 "Transformer" 好多, 雖然無咁靚), 而且成套戲都有笑料, 算係一個驚喜既地方! 至方劇情方面, 都預左唔會好有深度, 畢竟係改篇自美式英雄漫畫, d角色都係大忠大奸, 頂多出個一睇就知係奸扮忠既角色. 不過套戲一開始十分大美國主義 (d角色死都要死0向國旗旁邊.....), 之後其實都不時暗串美國賣軍火, 亦有反戰意識, 都算有教育意義ge~

五一放假就出街勞動左成日, 晨早起身出去彩虹道打室內場. 大家都打得唔錯, 四場贏左三場~ 哈哈~ 我個人都每場有得分有籃板, 之後仲送出一個 block shot 同一次 fast break 添, yeah! 其實不嬲都唔識打全場, 無論係防守進攻都唔知想點咁, 又覺得進攻時好難, paint 位人馬疊疊. 今次得阿強提醒要點, 開始比較掌握到進攻方式.

打完波就去左黃埔篤波, 篤左兩個鐘到就去左旺角join 埋 Ann 同 Emily 去第尾食飯. 由於做左大量運動 (全場比 3 on 3 更攰... ) + 無乜坐過既關係, 果晚胃口超好, 我都係第一次食完第尾既什扒餐+兩個雪糕後唔會有頂到上心口既感覺.

去得旺角難免又會上 shooting 5 睇波衫, 呢排睇中左 Josh Smith, 想買作客深籃色果件. (呢排鷹隊實在太勁~) 另外又想買過對波鞋, 因為而家呢對個低已經蝕左好多. 心目中想買 Dwight Howard 既 TS Lightspeed Howard. 睇黎又係一輸敗家既開始....

2008年5月2日星期五

MOSS hosted InfoPath Form with Web Services Data Connection

Overview

在上一篇文 Publish Browser Enabled InfoPath Form to MOSS 2007 中分享了製作 MOSS browser enabled InfoPath Form 的方法. 今次就再為InfoPath Form 加上 Web Services 既 Data Connection.

Reference

  1. InfoPath and Web Service data connection
  2. Data Connections in Browser Forms
  3. Data Connection Libraries
  4. Publish a form template to a server running InfoPath Forms Services
  5. How to: Deploy Form Templates That Contain Form Code
  6. MSDN - Visual Studio 2005 Tools for Applications

Steps

我的經驗告訴我, 所有與 SharePoint 扯上關係的 Development 都不會像表面所看那麼簡單... 一定有很多困難的地方. 這次都不例外, 看看上面列出的 reference link 數目之多就可知道...

在下面我只會例出簡單的流程, 並指出相對應的 reference.

  1. 當然是先要建立起一個web service吧. 這個用 Visual Studio 2005 可以輕鬆做到.
  2. 建立與web service溝通的 InfoPath Form Template. 在 InfoPath 2007 中的 "Design a Form Template" Wizard 可以讓你一步一步建立起以 web service 做為 data source 及 submit target 的 Form Template. 詳細請參考 Reference 1. 下面列出幾點要注意的地方︰
    2.1   在 "Design a Form Template" Wizard 中可以選 "Enable browser-compatible features
            only", 可以避免誤用與 browser 不相容的功能.
    2.2   在 "Tools" => "Form Options" => "Compatibility" 中選 "Design a form template that
            can ......"
    , 再將要 deploy / test 的 MOSS 的 URL 打入. InfoPath 就會用動替你找出
            template中任何與 server 不相容的地方, 並顯示在 "Design Checker" 中看到.
  3. 在 InfoPath 中, 將 Data Connection Convert 並存放在 MOSS 的 Data Connection Library 中, 等候 MOSS Administrator Approve (在 development 的時候, 應該你自己就是 administrator). 詳細請參考 Reference 3. 這步驟很重要, 不然之後在 browser submit form 的時候會出 Security Notice.
  4. 好~ InfoPath 的 Form Template 做完. 跟著就要去 MOSS 做 configuration. 先去 "Central Administration" Page, 再 "Application Management" => "Configure InfoPath Form Services", 然後選 "Allow cross-domain data access .....".
  5. 最後再去之前 Step 3 中 store Data Connection 的 MOSS Data Connection Library, 將所有要用的 Data Connection 都 Approve (當然要用 Administrator account Login). Step 4, 5 都請參考 Reference 2 & Reference 4.
  6. 最後將 Form Template Publish 去 MOSS, new 一張 Form 試一下, 如果沒問題就完成了!

Reference 5, 6 是關於如何在 InfoPath 中寫 custom code, 這將需要 VSTA. 而且 depoly 去 MOSS 的時候也有多些 configure 要做, 就不在這裡多講了.