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
Wednesday, 12 October 2016
Tuesday, 4 October 2016
Redirection page- Out of box publishing redirection page
There is a delay of 5 sec.
There is a delay of 5 sec.
- open sharepoint designer
- detach from layouts design
- edit in advance mode
- change the following
- <PublishingWebControls:RedirectControl SecondsBeforeRedirect="5" runat="server"/>
to
<PublishingWebControls:RedirectControl SecondsBeforeRedirect="0" runat="server"/> - 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.

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("");
//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("");

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.
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.
Subscribe to:
Posts (Atom)