Wednesday, June 17, 2015

Communication from K2 Smart form hosted in iframe from parent



Please find that when K2 smart form is hosted inside an iframe say for eg: in CRM, you want to trigger K2 event from CRM button click, you can achieve this as below:

in CRM using javascript to call

iframe.contentWindow.postMessage("hi","*"); (if "*" doesn't work use server url +port like http://10.2.3.4:82)


Then use data label in view / form and put below in expression to listen to the event.


<script type="text/javascript">$(document).ready( function(){ var eventMethod = window.addEventListener ? "addEventListener" : "attachEvent";var eventer = window[eventMethod];var messageEvent = eventMethod == "attachEvent" ? "onmessage" : "message";   eventer(messageEvent, function (e) { if (e.data=="Validate") { $("[title='btnValidateToolTip']").trigger("click"); var txtValidation = $("[title='dtlValidationToolTip']").text();  e.source.postMessage(txtValidation, "*"); } else {   $("[title='btnSaveToolTip']").trigger("click"); }  }, true); });</script>

End

Monday, June 1, 2015

Workspace error




When I go to the web occurs to me this error. 
User is the domain admin.  Created in IIS  full domain name, but still does not work.


Initialization failed: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: indexAn error has occurred.
Please contact your administrator.
Error:
Initialization failed before PreInit: Thread was being aborted.
Possible causes
- using anonymous logon in IIS while Windows security is specified in Workspace configuration
- current logged on user can not be verified against the Active Directory Membership provider
- please review log files for more information


Answers:

Following could be the condition

1. check if other users are able to access

if Yes then check for duplicate in workspace.userprofile table using below query
"
SELECT  userid
  FROM [K2].[Workspace].[UserProfile]

 group by userd having count(*) > 1
"

duplicate then remove one of them from the userprofile table and Bingo!!!!

2. Else
Open the workspace web.config file, search for Ldap you shoud see this LDAP://[domain]). At the end of the .com of the domain add :389 The correct string should look like this “LDAP://[domain]:389” Do an IIS reset and workspace should work.

Monday, March 30, 2015

K2 SmartForms - Close all the child windows on closing parent window using JavaScript

Requirement is to close all those windows that opens from parent window on close of parent window. we are not using Modal dialog window here.


we will use java script to achieve this as below.


1. In the parent form/view place a datalabel and place the expression below as new expression:


Use the button tooltip to fire on click event in client side and open the new window, store the window open in variable and close the variable beforeunload event of the form/window.


This will make sure you are closing the window before routing .

<script type="text/javascript">$(document).ready(function() { var winVar=null;  $(window).bind("beforeunload", function(){ if(winVar != null){winVar.close();} }); $("[title='TTAction Button']").click(function() { var urlText= document.getElementsByName("dtlDocumentumURL")[0].innerHTML; winVar= window.open(urlText, '_blank', 'modal=yes,toolbar=0,location=0,menubar=0');});});</script>




If you want more details about javascript expression in DataLabel, browse below link


http://blog.velocity-it.com/2014/10/07/how-to-call-jquery-or-javascript-code-in-a-k2-smartform/comment-page-1/


In IE the window.close () does not work, if there is a pdf downloaded in popup.


So use the below code for doing the same


<script type="text/javascript">$(document).ready(function() { var winVar=null;function openPopup(link) {  var html = "<html><head><title></title>"; html += "</head><body style='margin: 0;'>"; html += "<iframe height='100%' width='100%' src='" + link +"'></iframe>";  html += "</body></html>";   win = window.open("", "_blank", "resizable=1,status=0,toolbar=0,menubar=0");    win.document.write(html);    return win;}
  window.onbeforeunload=function() { if(winVar != null){  winVar.close();} }; $("[title='TTAction Button']").click(function() { var urlText= document.getElementsByName("dtlDocumentumURL")[0].innerHTML; winVar=openPopup(urlText);}); });</script>