Wednesday, 14 December 2016

error export Nintex workflow

Issue 

When trying to export the Nintex workflow we got the following errors.

 Error #1

Server Error in '/' Application.

Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.

http://go.microsoft.com/fwlink/?LinkID=314055

 Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.

http://go.microsoft.com/fwlink/?LinkID=314055


Error #2

Server Error in '/' Application.

Cannot find workflow in repository.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: Nintex.Workflow.NWException: Cannot find workflow in repository.

Source Error:


An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[NWException: Cannot find workflow in repository.]
   Nintex.Workflow.WorkflowRepository.get_Item(Guid wfId) +673
   Nintex.Workflow.ApplicationPages.ExportWorkflow.Page_Load(Object sender, EventArgs e) +990

[NWException: Error exporting workflow.]
   Nintex.Workflow.ApplicationPages.ExportWorkflow.Page_Load(Object sender, EventArgs e) +1523
   Microsoft.SharePoint.WebControls.UnsecuredLayoutsPageBase.OnLoad(EventArgs e) +300
   Microsoft.SharePoint.WebControls.LayoutsPageBase.OnLoad(EventArgs e) +49
   System.Web.UI.Control.LoadRecursive() +71
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3178



This is happening because you are accessing the workflow from site setting-> Workflows gallery (Nintex Workflow section) in top the level site (root of the site collection).


You need to access the workflow from site Nintex menu.



.

Wednesday, 12 October 2016

Powershell: starting a workflow on items in list within a view

I had so much trouble getting this to work I thought I would share this.

Limitation of this you can only process the items within the page of the view so you need to change your max page number to 1000.


#web site url
$siteurl="https://portal.peelschools.org/MLP"
#list name
$ListName="AODAACCE"
#workflow Name
$workflowName="DBUpdateReusable2010WF"
#view name Note: Change the view limit to 1000. This script is limited the page in a view.
$viewName="wf"

#content type name
$ctname="MLPRequiredAction"
$cTypes = $list.ContentTypes
$cType = $cTypes[$ctname]

$web = Get-SPWeb -Identity $siteurl
$manager = $web.Site.WorkFlowManager

$List = $Web.lists[$ListName]
$view = $list.Views[$viewName]

# Name of the Workflow
$assoc = $cType.WorkflowAssociations.GetAssociationByName($workflowName,"en-US")

$web.AllowUnsafeUpdates = $true
$wf = $cType.WorkflowAssociations
$data = $wf.AssociationData


write-host $view.Url
foreach($item in $list.GetItems($view))
{

 $mywf = $manager.StartWorkFlow($item,$assoc,$data,$true)

}
$manager.Dispose()
$Web.Dispose()


Error message 
Exception calling "StartWorkflow" with "4" argument(s): "This workflow association is not valid for use with this item."
At line:33 char:2
+  $mywf = $manager.StartWorkFlow($item,$assoc,$data,$true)
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ArgumentException

I had to add  the following line to resolve the error.
$web.AllowUnsafeUpdates = $true

Tuesday, 4 October 2016

Redirection page- Out of box publishing redirection page

There is a delay of 5 sec.


  1. open sharepoint designer
  2. detach from layouts design
  3. edit in advance mode
  4. change the following
  5. <PublishingWebControls:RedirectControl SecondsBeforeRedirect="5" runat="server"/>
    to
    <PublishingWebControls:RedirectControl SecondsBeforeRedirect="0" runat="server"/>
  6. publish the page



Friday, 12 August 2016

InfoPath and Javascript - accessing fields

I have found that if you reference the complete form name  #ctl00_ctl40_g_e8523f46_e657_46ec_aa9d_f8a08c446642_FormControl0_V1_I1_PB27 that form name changes when you republish the form.

The begin of the form name is dynamic and end is referring to the field in the form.

ctl00_ctl40_g_e8523f46_e657_46ec_aa9d_f8a08c446642_FormControl0_V1_I1_PB27

Should be written like this
//clear department and phone
$('[id$="FormControl0_V1_I1_T26"]').val("");
 $('[id$="FormControl0_V1_I1_T7"]').val("");

Not like this
//clear department and phone
 $('#ctl00_ctl40_g_84777929_920a_480e_81b1_1f2f20724097_FormControl0_V1_I1_T26').val("");
 $('#ctl00_ctl40_g_84777929_920a_480e_81b1_1f2f20724097_FormControl0_V1_I1_T7').val("");


To get the field information you can use debugger in IE (F12) or Chrome.






How to make Infopath and javascript work together - trick

Put the InfoPath form on web page and add a content edit web part with JavaScript file.

Here is an example


The issue for us was we couldn't enable the JavaScript within the infoPath form because we had to enable service on our production farm and we were concern about impacting other sites.  This was an easy workaround.

There are limitations to this solutions.
The form will time out after 30 minutes and you can't control the time out.  This particular form will not be open for an extended period of time so this works perfectly for us.