Archive

Archive for April 13, 2015

‘Saved’ event not triggering on ‘CRM Page’ hosted control – USD

April 13, 2015 2 comments

We have an Account form hosted in ‘CRM Page’ hosted control on USD. We got a requirement to navigate another page on CRM form Save event.

Below are the steps I initially followed

  • Created a new Hosted Control of type ‘CRM Page’
CRM Page Hosted Control

CRM Page Hosted Control

  • Go to ‘Events’ from Command Bar and open ‘Saved’ event
Saved event - Hosted Control

Saved event – Hosted Control

  • On ‘Saved’ event of Hosted Control, added a new ‘Action’ to Navigate to Bing
Navigate Action

Navigate Action

  • Save and close
  • Open the USD and open ‘Account’ record

But the ‘Saved’ event did not trigger when I click Save button from CRM page.

Reason

  • Looks like this is known issue with my USD version (Got fixed in latest USD version)

Fix

To fix this, below are workaround steps to hook the ‘Saved’ event to CRM hosted control.

  • Open ‘PageLoadComplete’ event of Hosted Control
PageLoadComplete Event

PageLoadComplete Event

  • Create a new ‘Action Call’
    • Action : ExecutionTimeout (Note : Create a new UII action if you can’t find ExecutionTimeout)
    • Data : milliseconds=6000
ExecutionOnTimeout Action Call

ExecutionOnTimeout Action Call

  • Create a new ‘Sub Action Call’
Sub Action Call

Sub Action Call

  • Add below Script using ‘RunXrmCommand’ Action

Script :

function hookSavedEvent(execContext)

{

window.open(“http://event/?eventname=Saved”); // notify USD of save

setTimeout(“top.ScanForData();”, 4000);

}

// Add ‘hookSavedEvent’ to Save event of CRM form

Xrm.Page.data.entity.addOnSave(hookSavedEvent);

Register Script Action

Register Script Action

  • Save & Close the forms
  • Close and reopen the USD client application to test the behavior now
  • Open ‘Account’ form, click on ‘Save’
USD CRM Form Save Action

USD CRM Form Save Action

  • We get a new tab with Bing page
USD - Navigated To Bing Page on Save

USD – Navigated To Bing Page on Save

🙂

Categories: CRM Tags: , , ,