Hi everyone,
Thought of sharing my learning from my last project in K2. Hope it would be helpful.
Thought of sharing my learning from my last project in K2. Hope it would be helpful.
Its not related to project specific but its from knowledge perspective.
1) K2 Smartforms server error-
Issue: Its my k2 five project, found that one
workflow threw exception like –‘Could not load file or assembly
'SourceCode.EventBus.MessageBusRecorder.dll' or one of its dependencies’.
On further troubleshoot tried to rerun existing workflow but
same exception. Moreover we tried to create simple workflow (sending email) but
it threw exception again. Thus we concluded that its not related to workflow
but something from workflow server or smartobject server.
After going through all solution we found the solution
Cause: K2 was installed in the default location (C:\Program
Files\K2\ for K2 Five
and C:\Program Files (x86)\K2\ for K2 blackpearl), then uninstalled and reinstalled to
a non-default folder. The paths to the event bus DLLs are not updated in the K2
database, causing the issue.
Workaround
To fix the
issue, change the path to the DLLs in the K2 database to the correct folder.
Run this
script against your K2 database to change the file path. Edit the script for
your environment by substituting the {incorrect path} value and {correct
path} value with those for your system. For example, REPLACE(asmFullName,'C:\Program
Files\K2\Host Server\Bin\','E:\Program Files (x86)\K2\Host Server\Bin\')
Code
Snippet:
UPDATE [K2].[Eventbus].[EventPolicyMapping]
SET asmFullName = REPLACE(asmFullName,'{incorrect path}','{correct path}')
SET asmFullName = REPLACE(asmFullName,'{incorrect path}','{correct path}')
2 2) Issue: It came surprise to me that K2
does not behave correctly when you put ‘_’ in form name.
You can see below form has ‘_’ in form name.
Workaround
We have created new form (deleted older and
created new one) . New form don’t have any underscore character.
Note: I have not renamed the form because
it will not change the system name of form.
Form below without ‘_’ in form name.
3 3) Issue :Checking at run time when need to
save or update in sql database. (using rule designer)
This is not an issue but was challenging to
implement from rule designer perspective.
We have application based on K2 smartforms
and all forms are encapsulated with views. We need to check at runtime whether
we need to decide that we need to add into sql table or update into table.
Workaround:
Here we have called read method of
Smartobject providing unique column ID and get return column value (saved in
variable to use later) .
At run time we checked if that return column
have value or not if it has value then
we need to call update method of SO
Else call add method of SO.
Snippet from Rule designer –
It worked very well for my requirement. Its
kind of tricky one with limitation of rule designer.
44) Issue :Not able to check in the view due to dependency errors in k2 smartforms/views
Explanation:-
Screenshot
above its throwing exception stating dependency errors when try to check in the
code.
Further its
showing red icon in layout of the view as below-
This happens because I have updated sql
table (deleted one column) and updated the smart object associated with that.
Since there was binding with the view and
that columns was used in rule hence this was exception.
Workaround: This can be dealt by
removing or updating the rule and by removing the references and delete the
fields from the view .
Learning New: I tried above solution
but it was not helping . I was able to remove rule but deleting the fields was
not helping . It was like kind of stuck . I tried iisrest, k2 service restart
etc.
Finally I won the battle by trying one
trick. I changed the datasource of the view (from General tab) and then
reverted back to original (please , ignore the warnings)
55) K2 pattern.
Although its very simple but I thought to
put it here because in most cases I have used MVC validation. K2 provides
validation patterns . It can be used in Forms and views for validation purpose.
Custom pattern can be added based on
regular expression. Please explore ‘add pattern’ above for more options.
66)
K2 Validation
This is kind making the view/forms control
in edit mode based on condition as below
Eg – if specific parameter have some value
then put view controls in edit mode. It will help developer when form need to
be in edit mode or read only mode.
77) Changing system names for K2 forms/Views
Many times developer used to come scenario
to rename view or forms or use Save as functionality.
In K2 world , renaming generally does not
change references from back end but changes only display name.
Workaround: One way is to deleted older one
and create new one but this is not everyone desire of . Hence another way is to
update the references from back end.
Please use below pointer –
Here I have updated ‘Form’ table . You can
see two columns – ‘Name’ and ‘displayname’ that need to target. Here ‘Name’
column is system name of the forms.
Hope all above may be helpful to you guys in sometime.
No comments:
Post a Comment