Documentation > CMS Template API Library > Asset > SetWorkflow(String,Status,Boolean)
SetWorkflow
Change the current asset to the workflow specified by the workflowName parameter.
public System.Boolean SetWorkflow(String,Status,Boolean)
Returns
true if the workflow is changed, false if not
Parameters
Name | Description | Type |
---|---|---|
workflowName | The name of the workflow that you want to change to. If no workflow with that name exists, an exception is thrown | System.String |
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"); if (!anAsset.SetWorkflow("Basic Workflow")) { Out.DebugWriteLine("Failed to set asset id {0} to new workflow error {1}", anAsset.Id, context.Error); }