Kaleo Engine in Liferay: withdrawing/deleting workflow programatically - liferay

Are there a straight forward solution on how to withdraw/delete a kaleo workflow programatically?
So basically what I wanted to do is that when I delete a custom asset I should also delete the kaleo workflow connected to it. As of now the default behavior, is that when I delete the custom asset there are orphaned data entry on the kaleo tables (like for example in the kaleoinstance table).

Which version of Liferay are you referring to? I'm looking at the BlogsEntryLocalServiceImpl calss in Liferay 7 right now, and I see that when a Blogs Entry is deleted (deleteEntry(BlogsEntry entry)), there's a call to deleteWorkflowInstanceLinks:
workflowInstanceLinkLocalService.deleteWorkflowInstanceLinks(
entry.getCompanyId(), entry.getGroupId(),
BlogsEntry.class.getName(), entry.getEntryId());
I am guessing you need to call this method in your *LSI class's delete method.
But maybe I misunderstand you?

Related

Liferay 7 Eclipse IDE override default categories behaviour

I need to create a portlet in order to change the default category behaviour/interface in Liferay 7.
My objective is to duplicate assetcategory table, expand and change its columns, and use this new table as a reference for categories within Liferay backend.
Therefore there are three key points my portlet has to update:
The category organization UI to create/update category tables on
DB. I’m able to create a new Liferay module project (panel-app template) which can present the UI backend interface from the side menu and interact with the DB.
Override default category selection panel within web content
properties panel (metadata > category select). I can create a new
Liferay module project fragment to override the
com.liferay.asset.categories.selector.web, however I’ve noticed I can
select only one file path (eg. META-INF/resources/view.jsp)
Override default asset publisher filter behaviour in order to allow
my custom categories selection. I’ve not yet investigated this
point.
I’m currently stuck at point 2 because after creating a new Liferay module project fragment, set the target Host OSGI Bundle to com.liferay.asset.categories.selector.web (which I believe is the correct one, please correct me if it isn't) and selecting the overridden files as META-INF/resources/view.jsp, I can’t proceed to redraw the category selection interface.
Here my attempts:
Updating the code view.jsp (eg. adding some text string) I can correctly
see them in the portlet.
Removing/commenting all the code in view.jsp an error is shown:
Asset category selector is temporarily unavailable
Selecting all three files available to be overridden in the main
portlet wizard (META-INF/resources/view.jsp, init.jsp and
init-ext.jsp) and updating view.jsp (like the first example) nothing
happen in the portlet
Some screenshot below:
Case 1
Case 2
Case 3
I need to create a portlet in order to change the default category
behaviour/interface in Liferay 7. My objective is to duplicate
assetcategory table, expand and change its columns, and use this new
table as a reference for categories within Liferay backend.
Just this alone sounds like a humongous task, bigger than what would fit into a stackoverflow question.
AssetCategories are used in every single content type, e.g. WebContent, Blog Articles, Message Board Posts, Wiki Pages, Knowledgebase Articles etc.. Replacing such a vital component by your own implementation is something that will safely ruin your next upgrade experience, because there you'd have to do this again, bringing your code to whatever changes will be made in the next version. And this "upgrade" includes Security Patches.
Overall, your premise sounds to me like a x-y problem and I'd rather recommend that you step back from your intended solution and look for other options to meet your business requirements. There surely are some.
My recommendation: Rather add something to the platform than ripping out a very central and generic component, reimplementing it in a business-specific manner. If you need a different filtering than Asset Publisher provides: Build your own Asset Publisher and implement the business specific rules there. Or think again about organizing your content in a different way than you currently organize it.
Unless you're already a Liferay Core Developer and are asking for a hint on how to change the implementation for the next version. But your question history here doesn't look like it.

How to Use Kaleo Workflow to Edit and Delete Record in Liferay

I am using Liferay 6.2 Enterprise Edition.
I have implemented Kaleo workflow when adding new record to an entity, I have no issue on it.
But I face problem when:
1) Editing a record. For example I have table Employee, I have record with column fullName and its value is Joe B, when I want to change it to Joe Bloggs, it will go to approval process and now its state is PENDING, but the old record is still exist, does Liferay has temporary table to store the new value (Joe Bloggs)? And how do we usually handle it inside Kaleo in Liferay?
2) Deleting a record. How Kaleo handle it? because I see Kaleo only play in column status, CMIIW.
On 2 cases above I have my own way to handle it manually outside Kaleo ways, but I hope there is such elegant ways in Kaleo which I dont know how right now
The value of all the fields related to the asset (even a pending asset) is stored in the workflowcontext field (as a hash map) of the kaleotaskinstancetoken table. I confirmed this in Liferay 7.0, pretty sure the same applies to 6.2.
Edit to add: You would of course access this via the API.
Edited again to add (piggy-backing off of the useful comment from #Shivam): See here to learn about workflow enabling custom entities for Liferay's workflow framework. Once you do that you really don't need to worry about the inner workings of the framework.
I don't think I understand question 2.

Is it possible to export selective customizations in a Dynamics CRM 2011 default solution

I am trying to see if this is possible, Basically I have customized several entities and among them I have modified the 'contacts' entity and created a new public view for it in the default solution in CRM 2011 online.
Now I want to export (just the 2 changes to the 'contacts' entity) to a new CRM 2011 instance.
Is there a way to export just these two changes or selectively decide which customizations you want to export to the new CRM instance?
I am trying to understand this for a typical "push QAed changes from staging to production" kind of scenario, are there any best practices for managing your changes in CRM 2011?
Thanks,
Deepak.
You can choose a particular entity to export, however, you can't choose to export/import just part of the entity. The forms, views, ribbon changes, and custom attributes will always come along for the ride.
By default you must export the component as a whole by creating a solution (managed or unmanaged) and then selecting "add existing component".
You can export portions of a component but to do that you must delve in to the XML of the exported solution. For example you can export just the ribbon for an entity, or just the form of an entity. The method is to just edit the customizations file and remove the portions you don't want to export/update. Your initial logic might be that if it is removed from the customizations file then won't it mean that it will be removed from the destination organization on import? No, that's not how it works. Read on for more info.
If you want to delete a field from an entity for example within a managed solution, how would you do that? You can't delete it from an org, export the updated version of the solution and import it in to the destination org as CRM will just keep the field. You must create a temporary solution with the entity with the attribute removed. Import the temporary solution to the destination org so that you can remove the actual solution you want to update. After you remove the actual solution you want to update, you update it to not have the field then re import. Once reimported you can remove the temporary solution. Messy.
Hope that helps.

How to fire code upon creation of a SharePoint list?

I'm aware of the event receivers on a list for items added etc. However, I have not found a way to fire code upon the creation of a list.
What I'm trying to do is associate a workflow with a list when the list is created (by the user through the UI).
Anyone any ideas?
thanks.
There are a couple of routes you can take...
You can write your own list definition where you have defined the workflow association - That way all lists created based on your list definition, will contain your workflow on default.
Or... depending on your workflow... write an EventReceiver your attach to all lists of the type you wish to attach your workflow to (can easily be achieved tru a feature) and have your event receiver associate the workflow when the first item is added.
or you can associate the workflow to the contenttype used in the list (your own contenttype you attach to your own list definition or a default SharePoint contenttype)
I don't know the rest of your solution, so it's defficult for me to suggest the best solution for you.
What I (almost) always do, is write my own list definition - That way I can avoid problems like this, now or in the future.
With SharePoint 2010 it is now possible to hook into the list creation event by overriding the ListAdded event in the SPListEventReceiver class.
I usually deploy an extra view page which is set to the default view. When the user creates the list he will be sent to the viewpage which contains the setup in code behind. The view page then calls a method ive created, which changes the default view, removes the setup view and change any navigation node pointing to the setup view.
There is probably no perfect answer to this question because there is no list added event receiver (if memory serves me correct).
I don't know if this is the case, but if you really just needed to register an itemadded (or updated, deleted, etc.) event to any new list, I believe you can register the those events at the site (SPWeb) level and they will fire on any new lists created.

Displaying a custom form on a new item event in SharePoint 3 document libraries?

Which is the best way to display a custom form for each new document being added to a specific document library?
I want the user to have some control over some actions that adding the document will cause - specifically, tasks created for users in a Task List, which the contributing user will have to OK before committing.
Is the best way to do this via a Workflow or an event handler?
Regards
Moo
For SharePoint server 2007:
A combination of a specialised content type and an event handler will give you the most control of the process (easier to debug too). A workflow is best for "easy" actions and is harder to make complex actions happen.
A workflow allows for more flexibility in assigning the workflow to different libraries by site admins.
Roll your content type and event handler into a feature that can be deployed. Assigning the content type to a list will allow you to take any data created by the standard form (remember you can create custom fields for really complex/custom data entry) and take any action required, including creating tasks based on the item.
Thanks for the answer, thats the route I was investigating but unfortunately I haven't found a way to make it work for Document Libraries - only Lists.
The problem I have come across is that aving a SPUtility.Redirect in the ItemAdded, ItemAdding, ItemCheckingIn or ItemCheckedIn event on the document library doesn't do anything at all, because there is no page related to the events - its all backend code being fired that is not linked to a web context, because its not the webpage doing the heavy lifting at that point but the Office integration.
All of the examples I have come across seem to rely on the fact that the EditForm.aspx or NewForm.aspx page is being displayed at the time the event is fired, which of course is not the case here.
This also leads to the problem that I cannot extend the EditForm.aspx or the CheckIn.aspx page to do what I want either, because Office 2007 circumvents both of these.
So, the only option left open to me at the moment is doing it through a workflow :/
Any further tips would be fantastic.
I may not understand your question, but is this close to what you're trying to do?
http://msdn.microsoft.com/en-us/library/ms550037.aspx
If not, in what way does this come up short?
A new "Content Type" with its New Form url set to the appropriate value should do the trick.
Unfortunately you may not be able to achieve what you are trying to with an Event Handler or a Workflow. You would ideally want the form to show up as soon as the user adds a new item to the library and a custom content type will do the trick.
Create a new Content Type. (Derive it from the existing Content Type)
Remove the default content type from the doc library.
Using the Object Model to set the New Form url to an aspx page or an Infopath form you've created.
Kind regards,

Resources