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.

If this post was helpful or you need more help please consider giving Thumbs Up and Tag me in your reply I'll be happy to help. If this post helped you solve your issue please click Accept as solution and provide Thumbs Up. This will help others find it more readily.

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.

If this post was helpful or you need more help please consider giving Thumbs Up and Tag me in your reply I'll be happy to help. If this post helped you solve your issue please click Accept as solution and provide Thumbs Up. This will help others find it more readily.

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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,933)