AXForum  
Вернуться   AXForum > Microsoft Dynamics CRM > Dynamics CRM: Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 19.11.2013, 06:12   #1  
Blog bot is offline
Blog bot
Участник
 
25,631 / 848 (80) +++++++
Регистрация: 28.10.2006
Microsoft Dynamics CRM Team Blog: How to Manage Auto Save for individual forms of entity
Источник: http://blogs.msdn.com/b/crm/archive/...of-entity.aspx
==============

In our previous blog we had discussed about how to manage auto save. We learned about the auto save capabilities and also discussed few scenarios where you might want to disable it. We discussed about how to control this at the organization level as well. The organization level setting turns off auto save for all the entities. In some scenarios, you may want to keep auto save enabled for all entities and only disable it for a specific form of an entity. In this blog we are going to discuss about how to control auto save for individual entities at the form level.

Forms support capability to attach java script method as OnSave event. One of the way to prevent auto save is to add a handler which prevent auto save. Let’s dig further and understand how to achieve this in Microsoft Dynamics CRM 2013.

Step 1 Create Java script file\method

Create a new Javascript file preventAutoSave.js with the following method.

function preventAutoSave(econtext) {

var eventArgs = econtext.getEventArgs();

if (eventArgs.getSaveMode() == 70) {

eventArgs.preventDefault();

}

}

A new value is added to save event mode i.e. AutoSave (value = 70). Other important values of Save Mode options are given below (Please refer CRM 2013 SDK Documentation for complete list)

Event Mode

Value

Save

1

Save And Close

2

Save and New

59

Save as Completed

58

AutoSave

70

Step 2 Upload this Javascript as webresource in CRM

Navigate to Settings > Customization > Customize the System. Navigate to Web Resources in Solution explorer. Create new web resource of type JScript.



Step 3 Associate Jscript as web resource with Form

Launch form editor for a respective form of the entity for which you want to block auto save. Form Editor can be launched from entity record (form Editor Command) or from Customization area.

Click on Form Properties > Events > Form Libraries > Add (add preventAutosave.js)



Step 4 Associate jscript method to prevent auto save as OnSaveHandler with form

In event handlers section of form properties window set event to OnSave and click Add to set preventAutoSave.js as library. Set preventAutoSave as the function and ensure that Enabled is checked. Please ensure that “Pass execution context as first parameter”is checked otherwise it will not work.



Step 5 Publish Customizations

Don’t forget to publish the customizations. You can find publish button on form editor or in solution explorer.

Now you will find that auto save now gets prevented for respective forms. If you have requirement to prevent auto save on save and close (e.g. navigating back \ browser back) then you can handle that as well in JavaScript with slight changes to prevent Save and Close.

function preventAutoSave(econtext) {

var eventArgs = econtext.getEventArgs();

if (eventArgs.getSaveMode() == 70 || eventArgs.getSaveMode() == 2) {

eventArgs.preventDefault();

}

}

Please note that save button will not show in the command bar if the auto save setting is turned on at the organization level. The save button will only show when the auto save setting is turned off. If you apply the approach described above to prevent auto save on background saves and or when people navigate away from the form, people have to explicitly save the record using the save button at the bottom of the form (Image below) or use the keyboard shortcut (Ctrl + S.)



Hope this clarifies how to manage auto save for individual form of entities.

Thanks,

Niraj Yadav

Microsoft Dynamics CRM






Источник: http://blogs.msdn.com/b/crm/archive/...of-entity.aspx
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
crminthefield: Podcast and Overview: Microsoft Dynamics CRM 2011 Update Rollup 12 Blog bot Dynamics CRM: Blogs 0 30.01.2013 01:11
crminthefield: Podcast and Overview: Microsoft Dynamics CRM 2011 Update Rollup 10 Blog bot Dynamics CRM: Blogs 0 17.08.2012 03:27
Microsoft Dynamics CRM Team Blog: Fast, Efficient Growth for Project Management Solution - Case Studies Blog bot Dynamics CRM: Blogs 0 01.02.2012 03:18
crminthefield: Overview: Microsoft Dynamics CRM 4.0 Update Rollup 17 Blog bot Dynamics CRM: Blogs 0 06.05.2011 09:11
Microsoft Dynamics CRM Team Blog: CRM MVPs Introduce the Microsoft Dynamics CRM Wiki Blog bot Dynamics CRM: Blogs 0 05.04.2011 00:13

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 19:40.