Solved

Generate SmartObjects in a workflow


Badge +4

Is there a way to generate SmartObjects as a workflow step so that they can be used later.

 

I have a workflow that creates a document library at an early stage of its process. I want to, at a later stage, perform actions like Get Documents and Update Document, etc. on the items in this document library. The problem is that the library doesn't exist until the workflow runs so I can't create the SmartObjects now that I need to call in the workflow.

 

Is there a way to create the SmartObjects on the library as a step in the workflow and make a reference so that I can call that SmartObject's methods later?

icon

Best answer by khanh1 21 June 2019, 01:45

View original

4 replies

Userlevel 6
Badge +16

Hi,


 


Perhaps, this might help.


http://help.k2.com/onlinehelp/k2five/userguide/5.2/default.htm#Create/K2ForSharePoint/Create/ReusingK2forSharePointArtifacts.htm%3FTocPath%3DCreate%7CK2%2520for%2520SharePoint%7CReusing%2520K2%2520for%2520SharePoint%2520Artifacts%7C_____0

Badge +9

Hi JessMeats

 

workaround to resolve this issue. Please follow these steps.

1) Navigate to the Library and click on Library Settings.

2) Under 'Content Types' you should see more than 1 type. Please remove all but 1 Content Types (you may want to take a screenshot for when we add them back later). You can do this by clicking on the content type and then selecting, 'Delete this content type'.

3) Navigate to the K2 Artifacts page and you will see 2 new links - one to 'Regenerate SmartObjects' and another to 'Regenerate SmartObjects and generate Views and Forms'. Please select the 'Regenerate SmartObjects'.

4) At this point, you should be able to change the Scope of the library. Please navigate to the 'Manage SmartObjects page and make sure the List/Library is selected for the scope.

5) Now, you should be able to navigate back to the Library Settings and add the Content Types back to the library. You should not need to regenerate the SmartObjects again.

 

There is a small bug here where the library gets stuck with a 'none' scope. If there are more than one Content Type on the library when the SmartObject gets created, the scope will be set to none. We have to regenerate the SmartObject on the Library to reflect a single Content Type. Once this is initialized, you are able to add additional content types back to the library.

 

Should you find the information from the article useful or leading you to the answer please mark as "Solution and/or Kudo", as it will assist other k2 developers with relevant information in the near future.

 

Best Regards

Elvis

 

[K2 will not accept any liability for any issues arising from actions taken in respect of the information provided by any forum member]

Badge +4

Hi Elvis. The problem is that the library doesn't exist yet. My workflow is creating a new SharePoint site from a template as part of its process. The site includes a document library that I want to interact with at a later point in the process. Going into the library settings and generating the SmartObjects as a manual task doesn't help because that would have to be done while the workflow is in progress, so I can't build the workflow to use them.

 

Khanh's repsonse looks more promising. I won't have time to try this out until next week, but I'll see whether that will solve my problem then.

Badge +4

I'm trying to use Khanh's method and getting errors. I have a template with the SmartObjects generated and the new library is created from the template.

 

When I try to use a SmartObject call to the library using the primary SmartObject and the site url and list ID, I get an error on the workflow telling me that the list does not exist. I've checked and the list ID I'm using as a parameter is correct.

 

When I go to the newly created library and click on the K2 Application button, it gives me a different message. I get told "SmartObject with name GetK2ApplicationSettings not found. Please rerun the K2 for SharePoint application Registration Wizard..." I tried that and still get the error. The site collection all this is happening on has K2 activated on it and if I go in through the Site Contents, I can see the K2 app and it looks like it should work, but I can't get into the K2 Application settings on that document library, so even manually creating SmartObjects for it is no longer an option.

 

Any ideas?

Reply