Skip to main content

Notifications

Announcements

No record found.

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 104

<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>

  • ba365guy Profile Picture
    ba365guy 2,948 on at
    RE: Having trouble setting a currency field(Not value but type to Dollars,Euro,Rupee etc) using Web API. I want to achieve this anyhow.

    Hi KashyapT

    Did it work for you. Let me know.

  • Suggested answer
    ba365guy Profile Picture
    ba365guy 2,948 on at
    RE: Having trouble setting a currency field(Not value but type to Dollars,Euro,Rupee etc) using Web API. I want to achieve this anyhow.

    Try the following:

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

    This will work

  • KashyapT Profile Picture
    KashyapT 104 on at
    RE: Having trouble setting a currency field(Not value but type to Dollars,Euro,Rupee etc) using Web API. I want to achieve this anyhow.

    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.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,432 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans