Wednesday, July 12, 2006
Changing a workflow state from API
Changing a workflow state from API
Version: Sitecore 5.1.1.18/5.2.0.9
Include these using directives:
using Sitecore;
using Sitecore.Data;
using Sitecore.Data.Items;
using Sitecore.Workflows;
using Sitecore.Configuration;
using Sitecore.SecurityModel;
Here is the code snippet with appropriate comments:
// getting the master database
Database master = Factory.GetDatabase("master");
// getting a sample item
Item itm = master.Items["/sitecore/content/home/news"];
// getting the item's workflow reference
IWorkflow wf = master.WorkflowProvider.GetWorkflow(itm);
// here we need either to login as a user with appropriate permissions
// to have access to workflow states/commands or disable security
using(new SecurityDisabler())
{
// executing the workflow command by calling the Execute method.
// it receives the ID of the command being invoked,
// the item that is in the workflow.
// Note that the command ID that we passed as the first parameter,
// should be a valid ID of any workflow command under the current workflow state
// that the item belongs to.
WorkflowResult result =
wf.Execute("{0FB92663-F44B-4E24-9CF2-B6D6CE786505}", itm, "my comments", false);
// Retrieving the result of the workflow command execution
Response.Write("Succeeded: " + result.Succeeded + "
Message: " + result.Message);
}
After the code above is succeeded, all actions that are tied to the new workflow state will be executed.
Wednesday, July 05, 2006
HTML Editor's context menu items
In order to disable some items in the Context Menu of the HTML Editor, you should modify the file \sitecore\shell\Editor\Configuration\AutoConfigure\Full.config
Please have a look at the contextmenu section.
<contextmenu>
<item name="Editing" value="False" />
<item name="Format" value="True" />
<item name="Insert" value="True" />
…
If you want to disable an item, you should set appropriate value to False.
Subscribe to:
Posts (Atom)