web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

Having trouble setting a currency field(Not value but type to Dollars,Euro,Rupee etc) using Web API. I want to achieve this anyhow.

(0) ShareShare
ReportReport
Posted on by 106

<html><head>
<meta charset="utf-8">
<title></title>
<meta>
<meta charset="utf-8"></head>
<body style="overflow-wrap: break-word;" onfocusout="parent.setEmailRange();">
<script src="ClientGlobalContext.js.aspx" type="text/javascript"></script>
<script>
function createFunc() {
try {
var name = document.getElementById("txtname");
//var lookUpObj = [];
//lookUpObj[0] = {};
//lookUpObj[0].Id = "E577A643-1DE7-E611-80F4-E0071B661F01"; //GUID
//lookUpObj[0].LogicalName = "pricelevel";
//var lookupValue = new Array();
//lookupValue[0] = new Object();
//lookupValue[0].id = "E577A643-1DE7-E611-80F4-E0071B661F01";
//lookupValue[0].name = "Price List";
//lookupValue[0].entityType = "pricelevel";
var accountData =
{
"name": name.value,
"emailaddress1": document.getElementById("txtemail").value,
"telephone1": document.getElementById("txtphone").value,
"fax": document.getElementById("txtfax").value,
"websiteurl": document.getElementById("txtwebsite").value,
"customertypecode": 1,
"TransactionCurrencyId@odata.bind": "/Currency(7b980A3D6E-792F-EA11-A812-000D3A3DFA9B)"      //This is where the problem is i believe.
//Attribute:SchemaName,EntityName:PluralName. //check this if error.
//"defaultpricelevelid_pricelevel@odata.bind": "/pricelevel(E577A643-1DE7-E611-80F4-E0071B661F01)"

//"defaultpricelevelid": lookupValue,
//,"defaultpricelevelid":
//{
// "logicalname": "pricelevel",
// "id": "E577A643-1DE7-E611-80F4-E0071B661F01"
//}
// Single Line of Text
};

//var accountData = {"name":"Raja Ram"};
//accountData.name = "Ram24344";

alert("hi" + JSON.stringify(accountData));
// Create account record
Xrm.WebApi.createRecord("account", accountData).then(
function success(result) {
// Show Account GUID
Xrm.Utility.alertDialog("Account created with ID: " + result.id, null);
},
function (error) {
// Show Error
alert("Error :" + error.message);
//Xrm.Utility.alertDialog("Error :" + error.message, null);
});
}
catch (e) {
alert(e.message);
}
}
function retrieveMultipleFunc() {
try {
var accName = document.getElementById("txtaccountname").value;

Xrm.WebApi.retrieveMultipleRecords("account", accName, "?$select=name,telephone1,fax").then(
function success(result) {
document.getElementById("txtname").value = result.name;
document.getElementById("txtphone").value = result.telephone1;
document.getElementById("txtfax").value = result.fax;
document.getElementById("txtemail").value = result.emailaddress1;
alert("Retrieved values: Name: " + result.name);
//perform operations on record retrieval
},
function (error) {
alert(error.message);
// handle error conditions
}
);
} catch (ex) {
alert(ex.message);
}
}

function retrieveFunc() {
try {
var vguid = document.getElementById("guid").value;
alert(vguid);
Xrm.WebApi.retrieveRecord("account", vguid, "?$select=name,telephone1,fax").then(
function success(result) {
document.getElementById("txtname").value = result.name;
document.getElementById("txtphone").value = result.telephone1;
document.getElementById("txtfax").value = result.fax;
alert("Retrieved values: Name: " + result.name);
//perform operations on record retrieval
},
function (error) {
alert(error.message);
// handle error conditions
}
);

} catch (ex) {
alert(ex);
}
}
function updateFunc() {
//var data =
//{
// "name": "Manchester United",
// "accountcategorycode": 2
//};
//// update the record
//Xrm.WebApi.updateRecord("account", "cc63bf48-e635-ea11-a813-000d3a3e1259", data).then(
// function success(result) {
// alert("Account updated");
// // perform operations on record update
// },
// function (error) {
// alert(error.message);
// // handle error conditions
// }
//);

var obj = document.getElementById("guid").value;

var objj = {
"name": document.getElementById("txtname").value,
"emailaddress1": document.getElementById("txtemail").value,
"fax": document.getElementById("txtfax").value,
"telephone1": document.getElementById("txtphone").value
}
Xrm.WebApi.updateRecord("account", obj, objj).then(
function success(result) {
alert("Account updated");
},
function (error) {
alert(error.message)
}
)
}
function deleteRecord() {
Xrm.WebApi.deleteRecord("account", "f18e31d8-e735-ea11-a813-000d3a3e1259").then(
function success(result) {
alert("Account deleted");
// perform operations on record deletion
},
function (error) {
alert(error.message);
// handle error conditions
}
);
}
</script>
<form>
<table id="1010">
<tbody>
<tr><td>GUID</td><td><input id="guid" type="text"></td></tr>

<tr>
<td>Search Name</td>
<td>
<input id="txtaccountname" type="text">
<button id="btnfind" onclick="retrieveMultipleFunc()" type="button">Find</button>
</td>
</tr>

<tr><td>Name</td><td><input id="txtname" type="text"></td></tr>
<tr><td>Email</td><td><input id="txtemail" type="text"></td></tr>
<tr><td>Phone</td><td><input id="txtphone" type="text"></td></tr>
<tr><td>Fax</td><td><input id="txtfax" type="text"></td></tr>
<tr><td>Website</td><td><input id="txtwebsite" type="text"></td></tr>
<tr><td>Relationship Type</td><td><input id="customertypecode" type="text"></td></tr>

</tbody>
</table>
</form>
<button id="first1" onclick="createFunc()" type="button">Create</button>
<button onclick="updateFunc()" type="button">Update</button>
<button id="second2" onclick="retrieveFunc()" type="button">Retrieve</button>
<button onclick="deleteRecord()" type="button">Delete</button>

</body></html>

I have the same question (0)
  • KashyapT Profile Picture
    106 on at

    I have tried with

    1) "TransactionCurrencyId@odata.bind": "/Currency(7b980A3D6E-792F-EA11-A812-000D3A3DFA9B)"

    2)"TransactionCurrencyId@odata.bind": "/Currencies(7b980A3D6E-792F-EA11-A812-000D3A3DFA9B)"

    3)"TransactionCurrencyId@odata.bind": "/transactioncurrencyid(7b980A3D6E-792F-EA11-A812-000D3A3DFA9B)"

    Nothing works. I get an error saying :

    An Error occurred while validating input parameters.

    Microsoft.OData.ODataException : An Undeclared property value was not found in the payload..

    In OData, only declared navigation properties and declared named streams can be represented as properties without values at and goes on....

    Please help.

    Thank you.

  • Suggested answer
    ba365guy Profile Picture
    2,950 on at

    Try the following:

    var entity = {};
    entity["transactioncurrencyid@odata.bind"] = "/transactioncurrencies(7b45E6AA1D-2838-EA11-A812-000D3A0914)";

    This will work

  • ba365guy Profile Picture
    2,950 on at

    Hi KashyapT

    Did it work for you. Let me know.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Pallavi Phade Profile Picture

Pallavi Phade 102 Super User 2026 Season 1

#2
Abhilash Warrier Profile Picture

Abhilash Warrier 55 Super User 2026 Season 1

#3
ManoVerse Profile Picture

ManoVerse 47 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans