Quantcast
Channel: Nintex Connect: Unanswered Threads
Viewing all articles
Browse latest Browse all 2462

Need to set a schedule every 15 minutes through code

$
0
0

I want to schedule a site WF every 15 minutes. I can only set it by whole hours through the UI, so I created 4 different schedules each starting (startdate) 15 minutes later. This actually works fine, nintex creates 4 different schedules on the same WF. Now I am trying to set the same thing through the use of the nintex webservice, but unfortunatly now nintex overwrites my schedule and I am stuck with only 1 schedule (with a startdate 45 minutes later then current time..., being the last schedule I created)

My code (simplefied):


public static void AddWorkFlowSchedule(SPFeatureReceiverProperties properties, string workflowName, string nintexCredentialConstantName, DateTime startTime, RepeatIntervalType repeatIntervalType, int interval )
{

using (SPWeb web = !(properties.Feature.Parent is SPSite) ? properties.Feature.Parent as SPWeb : (properties.Feature.Parent as SPSite).OpenWeb())

{

web.AllowUnsafeUpdates =true;
NintexWorkflowWS nintexWorkflowWs = new NintexWorkflowWS();
nintexWorkflowWs.Timeout = nintexWSTimeOut;
nintexWorkflowWs.Url = GetNintexWSUrl(web);
nintexWorkflowWs.Credentials = (ICredentials)WorkflowPublisher.GetRunTimeCredentials(web, nintexCredentialConstantName);
string startDataXml = "<startDataXml></startDataXml>";
nintexWorkflowWs.AddWorkflowSchedule("", workflowName, startDataXml, new Schedule()
{
  StartTime = startTime,
  RepeatInterval= new RepeatInterval() {
    Type = repeatIntervalType,
    CountBetweenIntervals=interval
},
MaximumRepeats = 0,
WorkdaysOnly = true,
EndOn = EndScheduleOn.NoLimit
}, true);

web.AllowUnsafeUpdates = false;
 }


}

 

In my feature activating eventreceiver I call

WorkflowPublisher.AddWorkFlowSchedule(properties, "WF1", "", System.DateTime.Now, NintexWS.RepeatIntervalType.Hourly, 1);
WorkflowPublisher.AddWorkFlowSchedule(properties, "WF1", "", System.DateTime.Now.AddMinutes(15),NintexWS.RepeatIntervalType.Hourly, 1);
WorkflowPublisher.AddWorkFlowSchedule(properties, "WF1", "", System.DateTime.Now.AddMinutes(30),NintexWS.RepeatIntervalType.Hourly, 1);
WorkflowPublisher.AddWorkFlowSchedule(properties, "WF1", "", System.DateTime.Now.AddMinutes(45),NintexWS.RepeatIntervalType.Hourly, 1);

We are using sps2010 with latest international nintex version. What am I doing wrong? Should I use object model, if so could you please link some examples?

Sander


Viewing all articles
Browse latest Browse all 2462

Trending Articles