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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 05.03.2011, 00:12   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
CRMScape: CRM 2011 Set Default Transaction Currency in JavaScript
Источник: http://crmscape.blogspot.com/2011/03...ansaction.html
==============

The following function uses JSON and OData to select the first Currency entity that is configured on your system and then sets the transactioncurrencyid lookup to be that currency.

This particular feature is just as relevant for CRM 2011 as it was for CRM 4.0, but it is easier to implement now.

The OData selection for this consists of the following:
/TransactionCurrencySet?$select=TransactionCurrencyId,CurrencyName

If you have multiple currencies, you can always add a filter to OData select to grab the specific currency that you need. This function uses the first currency returned.


<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9D7513F9-C04C-4721-824A-2B34F0212519:52a7ab38-69c7-43d1-af4c-72ab7f28da76" class="wlWriterEditableSmartContent">function SetDefaultCurrency() { var context = Xrm.Page.context; var serverUrl = context.getServerUrl(); var ODataPath = serverUrl +"/XRMServices/2011/OrganizationData.svc"; var odataSelect = ODataPath +"/TransactionCurrencySet?$select=TransactionCurrencyId,CurrencyName"; $.ajax({ type: "GET", contentType: "application/json; charset=utf-8", datatype: "json", url: odataSelect, beforeSend: function (XMLHttpRequest) { XMLHttpRequest.setRequestHeader("Accept", "application/json"); }, success: function (data, textStatus, XmlHttpRequest) { var myCurrency = data.d.results[0]; var idValue = eval('myCurrency.TransactionCurrencyId'); var textValue = eval('myCurrency.CurrencyName'); var thisEntityType ='transactioncurrency'; Xrm.Page.getAttribute("transactioncurrencyid").setValue([{ id: idValue, name: textValue, entityType: thisEntityType }]); }, error: function (XmlHttpRequest, textStatus, errorThrown) { alert('OData Select Failed: '+ odataSelect); } }); }
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
CRM DE LA CREME! CRM 4.0 Disaster Recovery Blog bot Dynamics CRM: Blogs 2 26.02.2016 08:23
jodonnell: Microsoft Dynamics CRM 2011 Product Team feels the need for speed Blog bot Dynamics CRM: Blogs 0 18.02.2011 10:11
Все о Microsoft Dynamics CRM: Как установить Microsoft Dynamics CRM 2011 Beta Blog bot Dynamics CRM: Blogs 0 31.10.2010 15:08
CRM DE LA CREME! Some more useful javascripts for MS CRM Blog bot Dynamics CRM: Blogs 0 04.05.2010 11:05
CRM DE LA CREME! Configuring Microsoft Dynamics CRM 4.0 for Internet-facing deployment Blog bot Dynamics CRM: Blogs 0 18.08.2009 11:05

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

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

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 10:29.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.