The answer to my original question could have worked as Mark suggested, by looking at Context.Site.Name during the onSaving event, but then I tried to go with the best practice and use UISaved pipeline, as it triggers only when the Sitecore user "Saves" from within the Sitecore Content editor, so that worked perfectly for my case.
I was trying to change my workflow state field, but for some reason the changes wouldn't reflect in the item after saving, however this is how it finally worked:
I added the following code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Sitecore.Caching;
using Sitecore.Configuration;
using Sitecore.Data;
using Sitecore.Data.Items;
using Sitecore.Pipelines.Save;
namespace Example.Workflows
{
public class SaveUIProcessor
{
public virtual void Process(SaveArgs args)
{
foreach (SaveArgs.SaveItem saveItem in args.Items)
{
var item = Sitecore.Context.ContentDatabase.Items[saveItem.ID, saveItem.Language, saveItem.Version];
if (item != null)
{
setWorkflowState(item);
}
}
}
protected virtual void setWorkflowState(Item item)
{
using (new Sitecore.SecurityModel.SecurityDisabler())
{
try
{
item.Editing.BeginEdit();
item.Fields["__Workflow"].Value = WorkflowID;
item.Fields["__Workflow State"].Value = ReviewStateID;
item.Editing.EndEdit(true,false);
}
catch(Exception ex)
{
Sitecore.Diagnostics.Log.SingleError("Error in workflow state set on saveui" + ex, ex);
}
}
}
}
}
I also added the following patch in a .config file for the processor, it ensures that my custom code runs before Sitecore.Pipelines.Save.WorkflowSaveCommand:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<processors>
<saveUI>
<processor mode="on" type="Example.Workflows.SaveUIProcessor, Example.Workflows" patch:before="processor[@type='Sitecore.Pipelines.Save.WorkflowSaveCommand, Sitecore.Kernel']" />
</saveUI>
</processors>
</sitecore>
</configuration>
After doing this, the changes reflected successfully.
this answer was also pretty helpful https://sitecore.stackexchange.com/a/923/3547
publisher
when publish is running.