trying to start workflow final

Discussions related to custom development with Select.
Post Reply
jbrown
Posts: 5
Joined: Tue Jul 26, 2016 2:25 pm

trying to start workflow final

Post by jbrown »

I've been tasked with reading through a local list of orders, trying to find them in SoftPro, and creating final workflow task if they are found. To kind of summarize where I've gotten to, I:

• Create a SelectServer object and test the authentication
• Use that object to get an IOrderStore
• Loop through my local list of orders
o For each order I look for a matching IOrderInfo matching our order number
o If I find it I open the IOrder
o Here’s where I’m at for the moment.

In trying to gather information about starting a workflow final for that order I did a search here on the forum and find answers like "there is currently no way to submit an order to workflow or assign a step to a user" and "there is no public API for workflow assignment, etc", with an indication that these sorts of things are coming. Is this functionality available now? Or is this still something that's coming soon?
Melissa McBerkowitz
Posts: 91
Joined: Wed Sep 10, 2008 3:33 pm
Location: Raleigh, NC
Contact:

Re: trying to start workflow final

Post by Melissa McBerkowitz »

That information is still correct - we do not yet have public APIs for workflow processes or for submitting an order from one workflow step to another. We do, however, have full API support for the checklist and requested tasks within the order itself, so if the final workflow task you're creating is one of those, you have everything you need within that IOrder object. If you need more info about that option, please let us know!
Melissa McBerkowitz
VP of Product Strategy, SoftPro
jbrown
Posts: 5
Joined: Tue Jul 26, 2016 2:25 pm

Re: trying to start workflow final

Post by jbrown »

Sorry, I may not have completed my due diligence in this investigation yet, but after a search in the SDK Documentation I don't find how to create a task and add it to the order. Stepping through my code I can see the tasks in the IOrder. Can you point me to the documentation around manipulating the task list itself?

Code: Select all

private void HandleFoundOrder(IOrder foundOrder)
{
            // Cast to dynamic to make order handling easier.
            dynamic order = foundOrder;
            IEnumerable<dynamic> tasks = order.Tasks;

            // Add a task here please
}
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: trying to start workflow final

Post by BobRichards »

This provides the template for creating Checklist and Requested tasks. Here I create a Requested Task and set up the bare minimum number of properties required - the description.

Code: Select all

public static void CreateTask(SelectServer ss, IOrder iOrder)
{
	// Get an instance of the desired task type and set properties.
	//  (Substitute "ChecklistTask" if you want to add one of those instead.)
	IOrderItem task = iOrder.CreateNew("RequestedTask");
	task.SetProperty("Description", DateTime.Now.ToString());

	// Get list of tasks and add all task types to it.
	IList tasks = (IList)iOrder.GetProperty("Tasks");
	tasks.Add(task);

	// As always, save the order if you changed it.
	IOrderStore os = ss.GetService<IOrderStore>();
	os.ApplyChanges(iOrder);
}
Bob Richards, Senior Software Developer, SoftPro
jbrown
Posts: 5
Joined: Tue Jul 26, 2016 2:25 pm

Re: trying to start workflow final

Post by jbrown »

I am getting the following error when I try to execute the CreateNew step:

Could not load file or assembly 'Microsoft.Scripting, Version=1.1.0.20, Culture=neutral, PublicKeyToken=7f709c5b713576e1' or one of its dependencies. The system cannot find the file specified.

It doesn't seem to be as simple as adding a using statement, and I don't find any obvious reference to add. I'm using .NET 4.6, can you tell me what reference I need to add to the project?
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: trying to start workflow final

Post by BobRichards »

Add "Microsoft.Scripting.dll" from the SoftPro client or server libraries to your project executable folder with the other Select DLLs. You do not need to add it to your project references, but it is needed for Select DLLs.
Bob Richards, Senior Software Developer, SoftPro
jbrown
Posts: 5
Joined: Tue Jul 26, 2016 2:25 pm

Re: trying to start workflow final

Post by jbrown »

Working up to a point, but when I get to the tasks.Add(task) I get a MemberAccessException. Is this a problem with accessing the order itself? I'm using an order that appears in my order list in SoftPro Select.
BobRichards
Posts: 1376
Joined: Wed Jan 15, 2014 3:50 pm
Location: Raleigh, NC
Contact:

Re: trying to start workflow final

Post by BobRichards »

Is your order read-only? The order must be opened as writable. Can you make any changes to the order and save it (such as Order.RelatedOrders)? I would need to see your code to make any other comments.
Bob Richards, Senior Software Developer, SoftPro
jbrown
Posts: 5
Joined: Tue Jul 26, 2016 2:25 pm

Re: trying to start workflow final

Post by jbrown »

thanks. was opening as read-only
Post Reply