I’ve created a library with a Scope activity using the Visual Studio Activity Creator extension. However, when I try to put a “Wait for … and Resume” activity under the scope, I get “Cannot place activity under scope ‘[scope name]’, as the activity requires persistence and the scope does not offer support for it.”
How do I add support for persistence to the scope? I’d guess that there’s an interface it has to implement, but I wouldn’t know which.
I’ll add another related question here - is there documentation for the UiPath Activities library? I haven’t been able to find anything beyond “how to make your first activity” but I may be looking in the wrong place. Thanks!
My custom package defines a few scopes in which other activities can be placed, and I would like to have it support persistent activities. An example of a scope that supports persistent activities is the Parallel For Each activity, so it must be possible.
@mcutlyp
Its not an interface to implement, all classes derived from CodeActivity inherit the ability, it is controlled via the read only property ‘CanInduceIdle’ which needs to be set to true.
Its harder to implement rather than just turning that on though, you’ll need to create Bookmarks for when your code pauses aswell as handle resuming from the bookmarks when you wake up, otherwise your scope will just go wonky and not know where to resume from.
May I ask, what is the scope for? Curious why you need it with a persistence activity.
@Jon_Smith
Understood - is there documentation around bookmarks and things that need to be considered when implementing persistence support in a custom activity/scope?
The scope is for interfacing with our ticketing system. The scope handles setting up auth for the REST API and then any child activity that needs to call the API can use the auth from the scope. The idea is that you can basically wrap the whole workflow in this scope and not have to think about auth’ing your API requests after that.
It’s probably possible to restructure the workflow so that the Wait for … and Resume activities are outside of the scope, but this would definitely make working with them a bit awkward. And in the interest of compatibility, I think it’s worth trying to make them persistence-aware.
Thanks!
Edit: I should add that I do have CanInduceIdle set to true on my custom scope and I’m still getting the error in the OP. (It extends ContinuableAsyncNativeActivity (set up by the Activity Creator extension) which seems to have CanInduceIdle set to true, but I’ve set it to true manually as well.)
Awesome, thanks for the additional context because this helps me to give better advice.
So, you are kinda re-inventing the wheel here.
Integration Services are here to solve your problem, they can handle the authentication for you for any activity, and whats better is they dont need a scope (anymore) for these things and the connection is basically managed project wide.
If you build your API as a Custom Connector in the Integration Service you will save yourself alot of time, effort and hassle.
Regarding bookmark documentation, I’d say its not really documented. Microsoft kinda gave up on their Workflow Foundation code stuff that UiPath implements so its kinda niche knowing how to do that stuff.
Thanks for the advice and sorry for the delay, I’ve just set up a custom connector for the API. It seems to be working nicely as a wrapper around the endpoints and I’m able to use it in Studio Desktop without issue. I’m particularly impressed that it generated a .NET type from a test request so I can use static typing with the response data.
I have one question: How would I integrate this with my existing Visual Studio-based library? Some activities, including a couple of (application-specific) scopes, are more than just wrappers around API endpoints so will need custom logic (which I’ve already implemented in my VS-based library). Since it involves scopes, switching the library to a Studio-based one won’t be possible.
Could you elaborate a bit more on the bookmark part? I’m trying to build a scope activity that supports persistence. I got it to work that the activity can be placed inside the scope and the message mentioned by OP is not showing anymore. But I now need to implement “An extension of type ‘UiPath.Activities.Contracts.Persistence.IPersistenceBookmarks’” but I’m not yet sure how.
Unfortunately not, as I mentioned above the bookmarking stuff didnt seem to be documented and I didnt have a good reason to make any kind of scope that can support persistence.
As I mentioned I believe its because you will be suspending the activity, mid execution, and as such it needs to know how to persist.
As above I’d suggest considering if you really need the scope to support it?