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 Apps / Data Conversion Issue
Power Apps
Answered

Data Conversion Issue

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello, 

I am getting an error regarding data type. I am saving two fields in the collection, Feature_ID and CPI_Name_ID. I have multiple rows in the collection So i understand that I have to use ForAll to Patch. I have written the following code

 

ForAll(CFeatureSelection, Patch('[dbo].[Feature_B_Tab]', Defaults('[dbo].[Feature_B_Tab]'),{Feature_ID:CFeatureSelection.Feature_ID, CPI_Name_ID: ABCScreenCast.CPI_Name_ID}))

CFeatureSelection and ABCScreenCast are Collections. CFeatureSelection has two fields, They are of Type Int in SQL Server database, When i type the code above, i get the following error
Untitled.png
I am not sure how to convert the data from Collection to int data type? Can someone please help ? thank you

Categories:
I have the same question (0)
  • timl Profile Picture
    36,785 Super User 2026 Season 1 on at

    Hi @Anonymous

    I'm not exactly sure but I think something like this will take you closer.

    ForAll(CFeatureSelection, 
     Patch('[dbo].[Feature_B_Tab]', 
     Defaults('[dbo].[Feature_B_Tab]'),
    {Feature_ID:Feature_ID,
    CPI_Name_ID: First(ABCScreenCast).CPI_Name_ID
    }
    ) )

    For each record in CFeatureSelection, this formula will insert a record in [dbo].[Feature_B_Tab] with a FeatureID that matches the FeatureID for the current record in CFeatureSelection. Since ABCScreenCast is a collection, the formula will insert the CPI_Name_ID of the first record in the ABCScreenCast collection.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hello @timl

    Basically "CFeatureSelection" in my code is Collection too. So I have used the code you suggested but unfortunately it is not working.

    It there any simple way to do Type Casting in PowerApps ? It should be pretty simple to cast String data from Collection to INT something like in any other programming language ?

  • Verified answer
    timl Profile Picture
    36,785 Super User 2026 Season 1 on at

    Hi @Anonymous

    The Value function converts a string to an int.

    https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-value

    If CFeatureSelection.Feature_ID is a string and [dbo].[Feature_B_Tab].[Feature_ID] is an int, this is the formula you would use.

    ForAll(CFeatureSelection, 
     Patch('[dbo].[Feature_B_Tab]', 
     Defaults('[dbo].[Feature_B_Tab]'),
     {Feature_ID:Value(Feature_ID), 
     CPI_Name_ID: First(ABCScreenCast).CPI_Name_ID
     }
     )
    )
    

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

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 551

#2
WarrenBelz Profile Picture

WarrenBelz 430 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 298

Last 30 days Overall leaderboard