Documentation > CMS Template API Library > Asset > SetWorkflowByAsset(Asset,Status,Boolean)
SetWorkflowByAsset
Change the current asset to the workflow specified by the workflowAsset parameter.
public System.Boolean SetWorkflowByAsset(Asset,Status,Boolean)
Returns
true if the workflow is changed, false if not
Parameters
Name | Description | Type |
---|---|---|
workflowAsset | This is an asset that represents the workflow that is found in /System/Workflows or in a project specific "Workflows" folder | CrownPeak.CMSAPI.Asset |
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"); Asset workflowAsset = Asset.Load("/System/Workflows/MyWorkflow"); if (!anAsset.SetWorkflowByAsset(workflowAsset, Status.Load("LIVE"), true)) { Out.DebugWriteLine("Failed to set asset id {0} to new workflow id {1} error {2}", anAsset.Id, workflowAsset.Id, context.Error); }