All posts by FeiHong

ServiceObject definition does not contain method. ServiceObject:<>.Method: <>

Recently I encountered an issue while deploying a package from one environment to another. While testing the smartobject after the deployment, the following error message pop up :

Figure 1 Smartobject definition error

Reason: this error is thrown when the underlying method (tables or stored procedure in this case) cannot be found. This could be due to deletion or when the external component is not setup yet.

Steps to create the above scenario:

  1. Create a few stored procedures
  2. Refresh the Service Instance so that Stored Procedures are retrieved from the DB .
  3. Create the smartobjects from the instances.
Figure 2 SmartObjects generated from the create method

4. Now go back to the DB and delete one of the previously created Stored Procedure and add another one. Then refresh again (but do not create or generate the smartobject yet):

Figure 3 Newly retrieved Stored Procedures

As can be seen in the above image, there is a difference between the stored procedures. [dbo].[GetAnotherThing] does not exist and a new stored procedure [dbo].[GetSomethingFromTableDrop] is added. When the SmartObject GetAnotherThing is executed, the error dialog in Figure 1 will be shown.

Most of us when generating SmartObjects will use the Service tester to do so and select the Create method (Figure 4). When the Create SmartObjects method is used, smartobject with the missing method will still be there.

Figure 4 Create SmartObjects

The reason is that when this method is used, it does not delete any smartobjects since it is a smartobject creation/update method (Figure 5).

Figure 5 Creating SmartObjects Dialog box

Instead use the Generate smartobject method (Figure 6), this method will display the smartobject to be deleted as well besides the Create/Update method, BUT the drawback is that, it does not allow you to select the category to create the smartobject to:

Figure 6 Generate SmartObject dialog


Do not be mistaken and think that when external components are deleted, and doing a refresh of the service instances and executing the create smartobjects method will remove smartobjects that is to be deleted. Use the generate smartobjects method to help verify whether any smartobjects are to be deleted. Hope this helps someone!

I ____ Project Manager (add your own words in the space)

So, have you added your words? depending on which position you are in, it can be any of the following:

1) I want to be a PM (very common when interviewing people)
2) I am a PM
3) I was a PM

So what makes someone want to be a PM? in my view, everyone wants to be directing others and not do the actual work. They are happy with attending meetings, taking minutes (provided they actually do that), coordinating meetings and on occasion do the presentation on the schedules and issues encountered, and they will be complaining to their team that being a PM is not easy as it is very time consuming because they have to coordinate meetings, attend meetings and the single phrase that irks (at least for me) “I have to take the bullet for the team”.

One thing I find most telling on whether the PM to be or claimed PM has the skills or knowledge is when it comes to scheduling, if the PM lacks the knowledge, they tend to over estimate the schedule and that might mean they will just add 5% (or whatever they fancy) to whatever schedule the team-mate came out with and when asked why 5% and not 10% since they are already buffing, they might say its a “gut feeling”.

Based on PMP definition:

”Project Management is the application of knowledge, skills, tools and techniques to project activities to meet project requirements. The Project Manager is the person responsible for accomplishing the project objectives.”(PMBOK® Guide, Third Ed., 2004, Section 1.3)

If everyone is to just accomplish the above points stated in paragraph 1, does that make them out to be a PM? Do they actually have the knowledge or skills necessary to meet the project requirements? and this is especially so if the project is a technical project.

In my view, to be a PM is more then doing what was stated above, it requires the unseen skills like:

– knowledge in the area of work (and I am not talking about coordinating or writing minutes), if its IT project, knowledge in the IT area
– necessary certification (PMP, CSITPM)
– leadership skills
– management skills

So if you want to be a PM (point 1) ensure that you actually have the necessary background or skills first before you actually become a PM. What can be worse then facing backlash from your own team members who knows that you know nothing beyond arranging for meetings and coordinating meetings! What’s more, without the background knowledge in the area of the project, you might be taken for a ride by the vendor. Most good PMs will have some knowledge in the area of the project, example if its a technical project then technical knowledge in that area.

If you are a PM (point 2), great! but have you ask yourself, are you actually able to inspire your team during difficult times (leadership skills), manage the schedule and risks as well as distribute the tasks accordingly (management skills) and have the necessary knowledge for the project (domain knowledge). Of course, it can be difficult to be up to date with the latest technical skills BUT that is no excuse to not try and keep up to date, believe me, your team will be impressed when you can actually rolled up your sleeves and help them in their coding. And you will probably not be taken for a ride by the vendor or your developers. So far in most projects I have been on, the customers will rather be talking to the technical PM (if the company actually have separate roles) then the general PM as they realised that they do not get any answers from the general PM since the general PM have to go back to the technical person to get the information.

If you were a PM (point 3), its either you went up next level (project director perhaps?) OR you decided that being a PM is not to your liking, either way, you have gone through the thick and thin of being a PM.

The above are just my own views. Do leave a comments if you have something to share.

Setting Exception Handling

In K2 activity, you can set how K2 should handle any exception that is being thrown by K2 BP.

Activity Exception Property screen
Exception Property Screen

Depending on which checkbox is ticked, it can mean the activity proceed on to the next activity or stop completely and throwing exception.

Let’s take a simple workflow with a Start and another two activity in sequence. The following table shows what will happen depending on the ticked box.

Activity Exception table
Activity Exception table

Hence, with that in mind, if your activity or events to be triggered are not that important to the completion of the tasks, you may use row 2 of just ticking the checkbox of Enable Exception Rule and if the activity should complete but the exception should be log then use row 4.

Of course, try the various combination to determine which suits your requirement the best and note that if you are using VS.NET, then you can always write your own logging mechanism to handle the errors.

How to access and manuipulate ActivityInstanceDestination XML field in Workflow

To access datafields in K2 workflow is pretty straigh forward, but to access the XML fields require a bit more work to get to the text. In the following, the K2 API code is used to access the InfoPath XML data

1) Load the XML field using XmlDocument. If you have more then one XML field used, then loop through the XMLfield, use a IF statement to determine which XML field to load

XmlDocument document = new XmlDocument();
for (int i = 0; i < WLItem.ProcessInstance.XmlFields.Count; i++)
    if (WLItem.ProcessInstance.XmlFields[i].Name == “ABC”)
    {  xmlDoc.LoadXml(WLItem.ProcessInstance.XmlFields[i].Value.ToString());

2) Once loaded, because K2 uses the namespace “my”. create a XmlNamespaceManager (as shown in the code below). Why the use of XMLNamespaceManager? From MSDN (MSDN URL) XmlNamespaceMaanager explanation:

Resolves, adds, and removes namespaces to a collection and provides scope management for these namespaces.

The namespace manager implements enumeration support in addition to adding and retrieving namespaces. You can loop through the information saved in the namespace manager by using the foreach construct.

Because the namespace manager provides a string comparison with the prefix and namespaces as objects, there is a performance improvement when using the namespace manager over the direct comparison of a string

System.Xml.XmlNamespaceManager xmlNSMgr = new System.Xml.XmlNamespaceManager(xmlDoc.NameTable);
xmlNSMgr.AddNamespace(“my”, xmlDoc.DocumentElement.GetNamespaceOfPrefix(“my”));

XmlNode RemarksNode = xmlDoc.DocumentElement.SelectNodes(<Insert the node structure here>, xmlNSMgr).Item(0);

node structure example: /my:myFields/my:Approver/my:Approver_Remarks

Full example: XmlNode RemarksNode = xmlDoc.DocumentElement.SelectNodes(“/my:myFields/my:Approver/my:Approver_Remarks”, xmlNSMgr).Item(0);

3) Once the node has been selected, you can manipulate the innerText. Example, I am updating the innertext of the node comments

Approver_Remarks.InnerText = tbRemarks.Text;

4) Now this is when some additional steps need to be done:

StringWriter _SW = new StringWriter(); // create a stringwriter
XmlTextWriter _XmlW = new XmlTextWriter(_SW); // create a new xml textwriter, writing to the stringwriter
xmlDoc.WriteTo(_XmlW); // write the xmlDoc to the xmltextwriter
string UpdatedXml = _SW.ToString(); // store the stringwriter value

//pass the XML value back to the XmlField

WLItem.ActivityInstanceDestination.XmlFields[“ApproverComment”].Value = UpdatedXml;

WLItem.Actions[“Approve”].Execute(); // Execute the action to update the field