Thursday, 28 December 2017

SharePoint 2013 - Usage Analytics (ViewsLifetime)

A - OBJECTIVE: 

This article is to share a case study about SharePoint usage analytics (pageviews specifically) which is captured and updated by SharePoint (out-of-the-box feature).

B - CASE STUDY & THE PROBLEM :

- Search Service Application has several interesting services, including (1) Search Analytics and (2) Usage Analytics, and we can make use of the value ViewsLifetime (a managed property in the search application) to show the pageviews at a certain item. 

- To view the value ViewsLifetime of a certain page, you can use the URL (path to be updated): http://sitecollectionURL//_api/search/query?querytext='path:http://sitecollectionURL/news/Pages/ArticleURL.aspx'&sortlist='ViewsLifeTime:descending' 



- This value can be retrieved and used in a Content Search webpart which makes use of the custom Display Items:


- You can modify the TailTrimming to get the full pageviews data at production.

- The problem happens when the value ViewsLifetime is not updated properly and no value is captured in the EventStore, and the pageviews does not work.


C - TROUBLESHOOTING & SOLUTION:

A couple of online questions have no answer, such as:

https://social.msdn.microsoft.com/Forums/office/en-US/bcbd2474-31a0-4b09-97cc-67fa19d9ef3f/usage-analytics-event-store-not-updating-popularity-reports-showing-0-delete-usage-receivers?forum=sharepointdevelopment

The value ViewsLifetime is updated by the timer job Usage Analytics which run once a day (usually at 1am) to analyse all raw usage logs captured by the timer job Usage Data Import (run once every 5 mins).

We checked the scheduled jobs related to the services, and they work:

- Further check showed that the receivers of the relevant services have worked well.

- We manually run the service Analytics, but the RequestUsage folder at C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\LOGS\RequestUsage is not updated



- We manually check the service Data Import, but the EventStore is not updated as well.



Solution: 

At the staging environment: (app & web roles are in the same server) we restarted the application server, and it worked. EventStore is updated properly again and the ViewsLifetime is updated.

At the production environment:



  • Step 3: you should both/either restart the wsstracing.exe service and/or drill down to the affected folder.
  • Step 4: we restarted the service wsstracing.exe but the problem could not be resolved.
  • Step 5: we rename the problematic folder (which seems to be corrupted) to AffectedFolder2, and re-create the same folder to let the service run. If the folder cannot be renamed (e.g. TimerJobUsage), please go inside the folder and delete all outdated files (with the last modified date is before today).



  • The issue at production is resolved!




D - USEFUL RESOURCE: 

1. https://www.linkedin.com/pulse/20140724173810-70514633-sharepoint-usage-report-in-sp-2013-is-merged-in-search-service-application

2. https://blogs.technet.microsoft.com/tothesharepoint/2014/01/23/view-and-configure-usage-analytics-reports-in-sharepoint-server-2013

3. https://blogs.msdn.microsoft.com/spblog/2014/04/03/sharepoint-2013-usage-analytics-the-story

Wednesday, 21 June 2017

Nintex Workflows 101

A - OBJECTIVE: 

This article is to review basic points of Nintex Workflows (on-premises version 2013).

Case Study: we will create a workflow to delete all items in a list.

B - TIPS:

To list all potential or encountered technical errors or operational issues (based on frequently asked issues in my experience):

1. Delete a workflow: go to Workflow Inventory page as follows

 




2.  Schedule workflows to run automatically

 



 
3.  Process Collection (i.e. list of SharePoint): you should create a workflow variable of type "Collection" to handle this:

 

4.  Assign Flexi Task: is an important control in Nintex Workflows, where you can:
  • Allow a user (e.g. approver) to have different actions (i.e. outcomes), and each outcome can have its own set of activities (i.e. unique Nintex Workflow controls)
  • Assign who can be the target audience of this task & send custom email notification to the user(s).
  • Customize a Task Form (similar like Nintex Forms) which is used by this particular target audience.
Important Note:

Lookup Fields in Flexi Task: you can create linked controls in (a) a Nintex Forms, or (b) Task Form in a Flexi Assign Task (workflow)

For example, when a user chooses a value in Publication control, the check-boxes will be updated accordingly



Issue: when it comes to workflow migration (i.e. import an exported workflow) to a new SharePoint farm, such Lookup controls will not work anymore with the following warning:



Work-around: you need to delete the Lookup control and re-configure it again. This approach is acknowledge & confirmed by Nintex technical team.

5. State machine: is a crucial concept where you can define the states of your workflow while various parties can involve in a certain state(s).




C - CASE STUDY:

We will create a simple workflow to loop through all items in a SharePoint list & delete all items in a scheduled job.



D - SOURCE CODE:


1. We will create a query list where a variable of type Collection (named colItemIDs) will be used to keep all Item IDs:






2.Create a workflow variable index to store the number of items:



 3. Create a Collection Operation to count the number of SharePoint list items:




4. Create a Run-If control to ensure that all operations are done when the list has some items:



5. Create a For-Each loop to run through all get the individual ID out of the collection of IDs, and store this value in a workflow variable strItemID:






6. Add a Delete Item control to delete an individual item:



7. Schedule the workflow using Nintex Scheduled Job.