4

I need to get the next activity definitions on a TridionActivityDefinitionData object using Core Service in Tridion 2011 SP1. My activity definition object represents an automatic activity with 2 next activities.

My problem is that using the code below, the property NextActivityDefinitions is null:

TridionActivityDefinitionData tridionActivityDefinition =
    client.Read("tcm:21-443-131088", readOptions) as TridionActivityDefinitionData;
Console.WriteLine(tridionActivityDefinition.NextActivityDefinitions);

I tried with simple readOptions:

ReadOptions readOptions = new ReadOptions()

but also with other flags. Still I get back null.

readOptions.LoadFlags = LoadFlags.Expanded | LoadFlags.IncludeAllowedActions |
    LoadFlags.KeywordXlinks | LoadFlags.WebDavUrls;

API doc says:

“Field Value: Will be null if the Activity Definition is read stand-alone. In the context of a Process Definition it will be set. The collection should be empty if this represents the last activity or it should contain exactly one activity, unless this represents a decision. Note that the next activity should be identified (linked) by title, not by Id.”

So my question is, how do I read the Activity Definition in context of a Process Definition using Core Service?

3

Probably

Will be null if the Activity Definition is read stand-alone. In the context of a Process Definition it will be set

is not quite clear. This mean, that when you read ActivityDefinition only basic data will be read, but if you read ProcessDefinition - you will get all data (PD data, activities Data + nextActivities).

So, you need something like this:

var ad = (TridionActivityDefinitionData)client.Read("tcm:98-373-131088", 
                                                                  _defaultReadOptions);
var pd = (TridionProcessDefinitionData)client.Read(ad.ProcessDefinition.IdRef, 
                                                                  _defaultReadOptions);
var resultActivity = (TridionActivityDefinitionData)pd.ActivityDefinitions
                                                      .First(x => x.Title == ad.Title);

Btw, I've tried on the current Tridion version (2013SP1) your code and it already works(for next activity only id and title are read).

  • Indeed it works (also in Tridion 2011). I'll accept this answer. Thanks for the code sample. – Mihai Cădariu Nov 21 '13 at 3:42
  • I meant, that your code (in top message) works now in 2013 SP1 - behaviour was changed and NextActivityDefinitions are read on reading AD. – Syav4eg Nov 21 '13 at 11:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.