Skip to content

Instantly share code, notes, and snippets.

Last active Aug 7, 2017
What would you like to do?
Link BPT in Web Site Publication using Coreservice API
static void Main(string[] args)
using (var client = Utility.CoreServiceClient)
// get the list of the publications.
var publications = client.GetSystemWideList(new RepositoriesFilterData());
foreach (var pub in publications.Where(p => p.Title.Contains("600") || p.Title.Contains("700"))
// Read Publication details.
var publication = (RepositoryData)client.Read(pub.Id, new ReadOptions());
// Check the BPT of that publication, if null then add the BPT to that.
if (publication.BusinessProcessType == null || publication.BusinessProcessType.IdRef == "tcm:0-0-0")
// Reading the BPT id from the app.config, But you can also to read it through the core service.
int sourceBptId = Convert.ToInt32(ConfigurationManager.AppSettings["SourceBptId"]);
TcmUri bptId = new TcmUri(sourceBptId, Tridion.ContentManager.ItemType.BusinessProcessType, new TcmUri(publication.Id).ItemId);
//Link the BPT id to that publication.
publication.BusinessProcessType = new LinkToBusinessProcessTypeData { IdRef = bptId };
client.Save(publication, new ReadOptions());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment