Calling a parent Form in k2 Smart Forms

  • 27 June 2015
  • 0 replies
  • 11 views

Badge +9


 

Symptoms


Calling a parent Form in k2 Smart Forms
 

Diagnoses


we are integrating K2 smartforms page in Dynamic CRM 2013. we have hosted all the k2 smartforms page in CRM page through Iframe. we want to call the CRM Parent page through JavaScript on click of k2 smartforms button click control or we want to refresh the parent crm form on click of k2 smartforms button control , and want to execute the method.

when we are trying to access the java script method we are getting access disabled error . could anyone please assist me how can we achieve in smartforms ?

 

Resolution

Customer was able to resolve the issue with the following steps:
from-k2-smart-form-hosted.html
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>

 




 

0 replies

Be the first to reply!

Reply