Sitecore Publish/Unpublish automatically - sitecore

I am using Sitecore 9.1 and I set future publish/unpublish dates for some of the items.
I found two articles to do this:
This article talks about
1. Download the AUTOMATED PUBLISHER module from the Sitecore Marketplace.
2. Have your Sitecore implementers write your own custom code that is triggered by a Sitecore Task.
https://www.techguilds.com/Blog/2018/11/scheduled-and-advanced-publishing-with-sitecore-part-2
and
This article, which advises to do it by patching values in the config file:
<agent type="Sitecore.Tasks.PublishAgent" method="Run" interval="00:00:00">
<param desc="source database">master</param>
<param desc="target database">web</param>
<param desc="mode (full or smart or incremental)">incremental</param>
<param desc="languages">en, da</param>
</agent>
https://community.sitecore.net/developers/f/8/t/5496
Is auto-publishing built OOB in any version (in my case 9.1) ?
If not, which of the above would be the preferred way to do this?

From another post, confirmed that you can use the config option. Tested it out and it works.

Related

Publishagent with sitecore 8.2 publishing service

For publishagent to auto publish Items that are in final state of workflow. I have made following changes in Config file:
<agent type="Sitecore.Tasks.PublishAgent" method="Run" interval="00:02:00">
<param desc="source database">master</param>
<param desc="target database">web</param>
<param desc="mode (full or smart or incremental)">incremental</param>
<param desc="languages">en, da</param>
</agent>
Items are not getting published.While changing the mode to smart is publishing items. Does this publish agent works in incremental mode with sitecore 8.2 publishing service?
There is a bug in the combination publish agent/incremental/publish service. The development team at Sitecore is aware and it will probably be fixed in a next version.
As far as I know, there is no patch available yet.

Sitecore. Disable a pipeline's processor

I need to patch Sitecore's pipeline to disable one of the processors.
Can I do that, or should I remove and implement whole pipeline?
There is nothing like disabling processor in Sitecore out of the box.
What you can do, you can create a patch config which will remove that processor. But you need to be aware that this processor will never be executed unless you change the configuration again and application is restarted.
Below is example how to remove RunQueries processor from the contentSearch.queryWarmup pipeline:
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<contentSearch.queryWarmup>
<processor type="Sitecore.ContentSearch.Pipelines.QueryWarmups.RunQueries, Sitecore.ContentSearch">
<patch:delete />
</processor>
</contentSearch.queryWarmup>
</pipelines>
</sitecore>
IMPORTANT:
Remember that Sitecore parses all the config files alphabetically, and then subfolders (alphabetically again). So your patch file must be added "after" the original config which adds the processor. You may want to put all your patches e.g. in App_Config/ZZ.Custom/my.patch.config.

Sitecore use of agents and tasks

In sitecore we have the possibility of agents and tasks. But it is not very clear when to use which. My situation: I want to run an (possible taking half an hour) importer each night at a specified time. The importer will import data from an external source into sitecore. What is better: an agent or a task?
They roughly mean the same thing.
In the web.config you can define scheduled agents under the <scheduling> section, however some out of the box agents are in the Sitecore.Tasks namespace. So they appear to be one in the same, but really everything is an agent.
In Sitecore itself, under /sitecore/system/tasks you will see definition items for the same thing. These are called "tasks" but in reality, they are just logical definition items that run based on the schedule. In fact, these are just a CMS-friendly way to define what's also in the web.config as agents. There exists a configured agent that processes these from the CMS:
<!-- Agent to process schedules embedded as items in a database -->
<agent type="Sitecore.Tasks.DatabaseAgent" method="Run" interval="00:10:00">
<param desc="database">master</param>
<param desc="schedule root">/sitecore/system/tasks/schedules</param>
<LogActivity>true</LogActivity>
</agent>
<!-- Agent to process tasks from the task database (TaskDatabase) -->
<agent type="Sitecore.Tasks.TaskDatabaseAgent" method="Run" interval="00:10:00" />
So if you want something to be changed in the CMS, create a tasks under the system section. If you want something to be for developers only, create a config patch and apply your own custom <agent> on whatever timer you want.

Varying content and presentation by host name in Sitecore 6.4

Scenario:
A section of the content tree is the home item for a site that runs under two host names (www.site1.com and www.site2.com
The purpose of the two host names is to differentiate between two target countries that are served with the same content, and the same organisation (marketing department, web editor etc.)
The content is, of course, identical across the two host names.
Except....
In a couple of places we need some small differences. A contact email, for instance, or a legal notice (these are both just Sitecore content). In other places we may wish to be able to change a presentation component for an item based on which host context it's in. We may wish to do this across all items from a specific template.
To complicate matters, the site is already cloned from another site (www.siteA.com), which is the source of several clones (some translated) for different countries. This is to enable us to push new items/content changes/features to our subsidiary companies. So all templates and presentation components are already shared across lots of host contexts and lots of portions of the content tree.
Is there any Sitecore functionality that would make this possible/simple - or do we need to code context testing into our presentation components (presumably alongside some configuration items within Sitecore to avoid hardcoding values)?
Great question. This is a long-shot, but it may work:
Why don't you create a new device for Site2 and in the cases where Site2 presentation data needs to change, configure the presentation settings for the Site2 device. If not, don't set them and the Default device will render the content. The hard part here will be configuring how the device will resolve. Maybe you can create a custom device resolver in the <httpRequestBegin> pipeline:
<processor type="Sitecore.Pipelines.HttpRequest.BeginDiagnostics, Sitecore.Kernel"/>
<!--<processor type="Sitecore.Pipelines.HttpRequest.DeviceResolver, Sitecore.Kernel"/>-->
<processor type="YourProject.Pipelines.HttpRequest.DeviceResolver, YourProject"/>
<processor type="Sitecore.Pipelines.HttpRequest.LanguageResolver, Sitecore.Kernel"/>
In your processor you can look at the host to determine which to use.
You can also define the Site2 device on a new <site ... /> node as Paul mentions below. Something like this:
<site name="site1" hostName="site1.com" rootPath="/sitecore/content" startItem="/home" ... />
<site name="site2" hostName="site1.com" device="Site2" rootPath="/sitecore/content" startItem="/home" ... />
Both Site1 and Site2 point to the same parts of the tree, they just use different devices.

Firing a SharePoint Workflow by updating a list item through List Webservice

I am developing, a simple SharePoint Sequential Workflow which should be bound to a document library. When associating the little workflow to a document library, I checked these options
Allow this workflow to be manually
started by an authenticated user
with Edit Items Permissions.
Start
this workflow when a new item is
created.
Start this workflow when
an item is changed.
Now I upload a document to this library and the workflow starts and for instance sends a mail. It completes and everything is fine.
When I select Edit Properties on the new Item and save a change, the workflow is fired again. Absolutely what we expected.
Even when copying a new Item into the library with help of the Copy.asmx Webservice, the workflow starts normally.
But now I want to update the item via the SharePoint WebService Lists.asmx.
My CAML goes here:
<Method ID='1' Cmd='Update'>
<Field Name='ID'>1</Field>
<Field Name='myDummyPropertyField'>NewValue</Field>
</Method>
The Item is being updated (timestamp changed and a dummy property, too) but the workflow does NOT start again.
This behaviour is reproducable on our development and test system.
Checking the error logs (C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\LOGS) I discovered a strange error message:
09/25/2008 16:51:40.17 w3wp.exe (0x1D94) 0x1D60 Windows SharePoint Services General 6875 Critical Error loading and running event receiver Microsoft.SharePoint.Workflow.SPWorkflowAutostartEventReceiver in Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c. Additional information is below. : The object specified does not belong to a list.
Anybody who can confirm this behavior? Or any solution hints?
I am keeping you informed of any developments on this topic.
Finally, we got through the support services processes at Microsoft and got a solution!
First, Microsoft stated this to be a bug. It is a minor bug, because there is a good workaround, so it may take some longer time, until this bug will be fixed (the support technician said something with next service pack oder next version (!)).
But now for the problem.
The reaseon
Let's take a look at the CAML code from my question:
<Method ID='1' Cmd='Update'>
<Field Name='ID'>1</Field>
<Field Name='myDummyPropertyField'>NewValue</Field>
</Method>
For any reason the Workflow Manager does not work with the ID, we entered in the second line. Strange, all other SharePoint commands are working with the ID, but not the Workflow Manager. The Workflow Manager works with the "fully qualified" document name. So, because we had no clue and didn't entered any fully qualified document name, the Workflow Manager defaults to the name of the current document library. And now the error message begins to make sense:
The object specified does not belong to a list.
Of course, the object (document library) does not belong to a list, it IS the list.
The solution
We have to add one more line to our CAML Query:
<Field Name='FileRef'>/sites/mySite/myDocLib/myFolder/myDocument.txt</Field>
The FileRef passes the fully qualified document name to the Workflow Manager, which - now totally happy - starts the workflow of the item.
Be careful, you have to include the full absolute server path, omitting your server name (found for example in ServerRelativePath property of your SPItem).
Full working CAML Query:
<Method ID='1' Cmd='Update'>
<Field Name='ID'>1</Field>
<Field Name='FileRef'>/sites/mySite/myDocLib/myFolder/myDocument.txt</Field>
<Field Name='myDummyPropertyField'>NewValue</Field>
</Method>
The future
Perhaps this undocumented behaviour will be fixed in one of the upcoming service packs, perhaps not. Microsoft Support apologized and is going to release an MSDN Article on this topic. For the next month I hope this article on stackoverflow will help developers in the same situation.
Thanks for reading!
We faced a similar issue with an Approval Workflow.
To solve it, we wrote our own Event Receiver and attached it to the list.
Depending on whether the item was updated or edited, we then fired the Approval Workflow.
Hope this helps...
I've encountered this issue as well and found out that once a workflow has started, it cannot be re-started automatically, no matter how you update the item. You can, however, manually start the workflow again, as many times as you like.
I have seen the same behavior. But then you get posts like this, showing people how to create one per day to set up email reminders.