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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / How to save a integer ...
Power Pages
Unanswered

How to save a integer value to a double field through web api

(0) ShareShare
ReportReport
Posted on by 15

When I use the web api to update a double field, and the new value is a integer (no decimal), the result becomes error with the following message.

Invalid Attribute Value Type for xxx. Expected: Double (either Decimal or Float or Money), Found: System.Int32

 

The code is as follows.

function updateRecordAttribute(col, recordObj) {
 var attributeName = col.name,
 value = recordObj[attributeName],
 newValue = 5;
 if (newValue != null && newValue !== value) {
 appAjax('Updating...', {
 type: "PUT",
 url: "/_api/contacts(" + recordObj.id + ")/" + attributeName,
 contentType: "application/json",
 data: JSON.stringify({
 "value": newValue
 }),
 success: function(res) {
 table.updateRecord(attributeName, newValue, recordObj);
 }
 });
 }
 return false;
 }

 

So, how can I save a integer value in the double field?

I have tried to parse the value to double through number() and parseFloat(), but the result have not changed.

Categories:
  • Inogic Profile Picture
    1,297 Moderator on at

    Hi @bjdc ,

    As per our understanding, you facing the issue of Invalid Attribute Value Type for xxx. Expected: Double (either Decimal or Float or Money), Found: System.Int32

    To ensure that the newValue is treated as a double and not an integer, you need to explicitly convert the newValue to a double before including it in the API request. Additionally, make sure that the field name in the payload matches the expected format for your API. 

    Here’s the corrected function:

    function updateRecordAttribute(col, recordObj) {

        var attributeName = col.name,

            value = recordObj[attributeName],

            newValue = 5;

     

        // Convert the newValue to a double

        var doubleValue = Number(newValue); // or parseFloat(newValue);

     

        if (doubleValue != null && doubleValue !== value) {

            appAjax('Updating...', {

                type: "PUT",

                url: "/_api/contacts(" + recordObj.id + ")",

                contentType: "application/json",

                data: JSON.stringify({

                    [attributeName]: doubleValue

                }),

                success: function(res) {

                    table.updateRecord(attributeName, doubleValue, recordObj);

                },

                error: function(err) {

                    console.error('Error:', err);

                }

            });

        }

        return false;

    }

    var col = { name: "yourDoubleField" };

    var recordObj = {

        id: "some-record-id",

        yourDoubleField: 3.14

    };

    updateRecordAttribute(col, recordObj);

     

    Thanks!

    Inogic Professional Services: Power Platform/Dynamics 365 CRM
    An expert technical extension for your techno-functional business needs
    Drop an email at crm@inogic.com
    Service: https://www.inogic.com/services/
    Tips and Tricks: https://www.inogic.com/blog/

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Pages

#1
Mohsin Ali Profile Picture

Mohsin Ali 18

#2
11manish Profile Picture

11manish 14 Super User 2026 Season 2

#3
Harshit Chaubisa Profile Picture

Harshit Chaubisa 4

Last 30 days Overall leaderboard