Documentation > CMS Template API Library > Asset > CreateBranch(Asset,Boolean)

CreateBranch

Use this to create a branch from another asset.

public CrownPeak.CMSAPI.Asset CreateBranch(Asset,Boolean)


Returns

The newly created asset

Parameters

NameDescriptionType
srcAsset The asset we are bramching from. It must have workflow. CrownPeak.CMSAPI.Asset
branchWcoSnippets Optional: If the asset has snippets, should they also be branched. Defaults to false. New snippets will have names automatically generated by the CMS. System.Boolean

Code Example

C#

Sample:
Asset loadedAssetToBranch = Asset.Load("/Site/AssetIWantToBranch");

//Call it like this to avoid branching snippets:
Asset newBranch = Asset.CreateBranch(loadedAssetToBranch);
if (!newBranch.IsLoaded)
{
  Out.WriteLine("Branch Failed: " + context.Error);
}
//You would call it like this, if you wanted to also branch snippets :
Asset newBranch = Asset.CreateBranch(loadedAssetToBranch, true);
if (!newBranch.IsLoaded)
{
  Out.WriteLine("Branch Failed: " + context.Error);
}

Connect with Crownpeak