Documentation > CMS Template API Library > Asset > SetWorkflow(Int32,Status,Boolean)

SetWorkflow

Change the current asset to the workflow specified by the workflowId parameter.

public System.Boolean SetWorkflow(Int32,Status,Boolean)


Returns

true if the workflow is changed, false if not

Parameters

NameDescriptionType
workflowId The id of the workflow that you want to change to System.Int32
status Optional: Pass null to keep the asset in the same state, otherwise you will go to the state you provide. Defaults to null. CrownPeak.CMSAPI.Status
executeStep Optional: Whether or not to execute the current step when you go to the new workflow. Defaults to false. System.Boolean

Code Example

C#

Sample:
Asset anAsset = Asset.Load("/Path/ToChange");
int workflowId = 11;
if (!anAsset.SetWorkflow(workflowId, Status.Load("LIVE"), true))
{
  Out.DebugWriteLine("Failed to set asset id {0} to new workflow id {1} error {2}", anAsset.Id, workflowId, context.Error);
}

Connect with Crownpeak