cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
akg1421
Helper I
Helper I

Patch function Error "expected type Record. Found type Text" with Choice column & Text input

Collection 'HSEScoreValues' made with below formula & storing data OK but when Patching to SP List it gives error of expected type Record / Found type Text:

 

Collect(
    HSEScoreValues,
    {
        project_name: DataCardValue1.Selected.Value,
        category: Text(LookUp(
            'HSE-CategoryQuestion',
            Question = QuestionLabel.Text,
            ThisItem.Category
        )),
        question: QuestionLabel.Text,
        score:Value(ScoreTextInput.Text),
        survey_date: DataCardValue2.SelectedDate
    }
)

 

Data saved is in tabular form as expected/required:

Snap 2021-08-02 at 11.56.11.png

 

Error is in Patch function:

Snap 2021-08-02 at 12.09.38.png

 Both with list columns 'Project Name' & 'Category' it is expecting type Record when they are actually Choice fields and should accept Text value easily.

 

I tried with Collect function where I remove .Value from Datacard.Selected.Value (Datacard.selected) the error goes but Collection now saving data in 'Project Name' as collection (not as desired)

 

Collect(
    HSEScoreValues,
    {
        project_name: DataCardValue1.Selected,
        category: Text(LookUp(
            'HSE-CategoryQuestion',
            Question = QuestionLabel.Text,
            ThisItem.Category
        )),
        question: QuestionLabel.Text,
        score:Value(ScoreTextInput.Text),
        survey_date: DataCardValue2.SelectedDate
    }
)

 


What is the right way to Patch values here?
 @WarrenBelz @BCLS776 @CNT @Pstork1 @yashag2255 @Krishna_R @RandyHayes @eka24 @Krishna_R @yashag2255 @Nogueira1306 @KvB1 @rubin_boer @StalinPonnusamy @RandyHayes @BCLS776 @DylanSimons @BCBuizer @Jeff_Thorpe @RezaDorrani @PG_WorXz10 @Nogueira1306 @Sid_Jafri @Krishna_R 

2 ACCEPTED SOLUTIONS

Accepted Solutions
PG_WorXz10
Resident Rockstar
Resident Rockstar

Hi @akg1421 ,

 

For Choice fields would try below formula in your patch code ? 

 

ChoiceField:{Value:"Your Value"}

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

v-albai-msft
Community Support
Community Support

Hi @akg1421 ,

Two things you should pay attention:

1. Make sure if you have enable "Can add values manually" for your Choice column.

valbaimsft_0-1627976595902.png

2. Then the formula should be like this:

 

ForAll(HSEScoreValues,Patch('HSE-Report',Defaults('HSE-Report'),{'Project Name':{Value:project_name},

Category:{Value:category},.....}))

 

Here is a simple example of mine:

valbaimsft_0-1627976831066.png

Best regards,

Allen

View solution in original post

5 REPLIES 5
PG_WorXz10
Resident Rockstar
Resident Rockstar

Hi @akg1421 ,

 

For Choice fields would try below formula in your patch code ? 

 

ChoiceField:{Value:"Your Value"}

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

v-albai-msft
Community Support
Community Support

Hi @akg1421 ,

Two things you should pay attention:

1. Make sure if you have enable "Can add values manually" for your Choice column.

valbaimsft_0-1627976595902.png

2. Then the formula should be like this:

 

ForAll(HSEScoreValues,Patch('HSE-Report',Defaults('HSE-Report'),{'Project Name':{Value:project_name},

Category:{Value:category},.....}))

 

Here is a simple example of mine:

valbaimsft_0-1627976831066.png

Best regards,

Allen

View solution in original post

StalinPonnusamy
Community Champion
Community Champion

Hi @akg1421

 

Please try this. Lookup line says it references other SP list

 

Collect(
    HSEScoreValues,
    {
        project_name: DataCardValue1.Selected,
        Lookup:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
                        Id:ThisItem.Category.Selected.Value,
                        Value:ThisItem.Category.Selected.Value},
        question: QuestionLabel.Text,
        score:Value(ScoreTextInput.Text),
        survey_date: DataCardValue2.SelectedDate
    }
)

 

StalinPonnusamy
Community Champion
Community Champion

Hi @akg1421

  • Please find the sample for your reference
  • Previously mentioned "Lookup" is nothing but your filed name on the list 1 which references List 2

 

Collect(
    HSEScoreValues,
    {
        project_name: DataCardValue1.Selected,
        ColumnName:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
                        Id:ThisItem.Category.Selected.ID,
                        Value:ThisItem.Category.Selected.Text},
        question: QuestionLabel.Text,
        score:Value(ScoreTextInput.Text),
        survey_date: DataCardValue2.SelectedDate
    }
)

 

 

Working Sample for reference:

 

Patch(
    'Aisle Assignment',
    Defaults('Aisle Assignment'),
    {
        Title: DataCardValue5.Text,
        'Aisle Number': {
            '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
            Id: ComboBox2.Selected.ID,
            Value: ComboBox2.Selected.Title
        }
    }
)

 

 

 

@PG_WorXz10  *Wow!* in owen wilson's voice

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (1,427)