|
05.03.2011, 00:12 | #1 |
Участник
|
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, напишите личное сообщение администратору. |
|
|
|