Archive

Posts Tagged ‘Auto Save’

Duplicate detection functionality in CRM 2013

In CRM 2013, Duplicate record detection feature on create/update form has been removed due to the ‘Auto Save‘ functionality, which saves the form frequently.

Below are the 2 ways we can bring back the functionality.

Solution provided in CRM 2013 SDK 

  • In SDK there is a recommend approach to enable the duplicate detection feature on a required entity Create\Update form.
  • Download the CRM 2013 SDK, navigate toSDK\SampleCode\JS\DuplicateDetection\ReadMe.docx” document to get more information.
  • Here is an useful article with screen shots on the same.

Note –

  • We might need to disable your ‘autosave’, otherwise ‘autosave’ keeps triggering the duplicate detection
  • Refer this article how to skip autosave on onload or onsave.

CRM 2013 Duplicate Detection tool codeplex

  • There is a solution on codeplex which gives you the duplication detection functionality.
  • Download

🙂

Identify “Auto Save” in JScript onload & onsave events – CRM 2013

December 30, 2013 1 comment

CRM 2013 has got a new ‘Auto Save” feature which periodically saves the form after new data entered.

Problem with frequent auto save

  • The problem with this design is whenever auto-save fires, it causes  unwanted execution of the registered onload & onsave events.

To identify ‘Auto Save’ event in ‘onload & onsave’ below is useful approach

On Save 

  • Check  the ‘Save Mode’ of ‘Event Args’, If Save Mode is ‘70’ then save event is caused by ‘Auto Save’
  • Make sure to check ‘Pass execution context as first parameter’ while registering ‘onsave’ event
Passing execution context

Passing execution context

function onsave(eventArgs) {

var saveMode = eventArgs.getEventArgs().getSaveMode();

// 70 – AutoSave

if (saveMode == 70) {

alert(“Save caused by AutoSave”);

// By setting Form dirty, we will make sure the traditional save event executes when you click on ‘Save’ button

Xrm.Page.data.setFormDirty(true);

}

else {

alert(“Traditional Save event”);

}

}

Note

  • Since the ‘AutoSave’ periodically saves the form data, you might not get traditional ‘onsave’ event fired.
  • If you want your logic to be executed in traditional ‘onsave’ event, set form dirty to ‘true’ in ‘AutoSave’ save mode.

On Load 

‘onload’ event caused by ‘AutoSave’ does not clears the global variables. So use below steps to check ‘AutoSave’ event on ‘onload’

  • Declare and set a global variable
  • Check the variable on onload event

var formLoaded = false;

function onload() {

if (!formLoaded) {

alert(“Traditional form load happend !!!”);

}

formLoaded = true;

}

  • Above function the ‘If’ block executes only first time when you open the form

🙂

Categories: CRM 2013 Tags: , ,