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 / an issue encountered ...
Power Apps
Answered

an issue encountered while developing a rating system in SharePoint.

(2) ShareShare
ReportReport
Posted on by 190
Dear Experts
 
I am writing to request your assistance with an issue encountered while developing a rating system in SharePoint. The system comprises two SharePoint lists:
 
  1. The first list stores items awaiting rating.
  2. The second list stores scores submitted by raters, with a lookup column intended to link each score to the corresponding item in the first list.
I have encountered difficulties in writing the correct code for the function that should pass the item's ID to the lookup column in the second list. I believe the syntax for assigning the lookup column value via a Patch statement may be incorrect, preventing the system from properly associating scores with their target items.
 
Could you please help review the configuration and code logic? Your insights on the correct method for setting a lookup column's value when using the Patch function to add a new record to the second list would be greatly appreciated.
 
Thank you for your time and support. I look forward to your guidance.
 
Thanks a lot in advnace
 
Categories:
I have the same question (0)
  • Suggested answer
    Haque Profile Picture
    3,653 on at
    Hi @GGG666,
     
    I would suggest you to skim through the point numbers 2 and 3 in this blog post.
     
    The code you have produced for patching or updating the score record with a lookup to the item,  needs a bit of slight adjustment to correctly set the lookup column. The key is to patch the lookup column as a record with Id and Value properties, including the required @odata.type.
     
     
    When you are done with the blog, please try to adapt this code:
     
    If(
        IsBlank(
            LookUp(
                ScoresList,
                AIITLE.Id = RecordsGallery1.Selected.ID &&
                Rater = User().Email
            )
        ),
        Patch(
            ScoresList,
            Defaults(ScoresList),
            {
                AIITLE: {
                    '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
                    Id: RecordsGallery1.Selected.ID,
                    Value: RecordsGallery1.Selected.Title
                },
                Rater: User().Email,
                创新性: Rating2.Value
            }
        ),
        UpdateIf(
            ScoresList,
            AIITLE.Id = RecordsGallery1.Selected.ID &&
            Rater = User().Email,
            {
                创新性: Rating2.Value
            }
        )
    )
    
     
    Please let me know if you are assisted!
     
     

    I am sure some clues I tried to give. If these clues help to resolve the issue brought you by here, please don't forget to check the box Does this answer your question? At the same time, I am pretty sure you have liked the response!
     
     
     
  • Suggested answer
    Kalathiya Profile Picture
    2,456 Super User 2026 Season 1 on at
    Hello @GGG666,

    It looks like the error is happening because RecordsGallery1.Selected is a record, but the AIITITLE field is expecting a specific value. You need to reference the column inside the selected record, for example RecordsGallery1.Selected.AIITITLE.

    You can try updating your formula like this:

    If(IsBlank( LookUp( 'YourListName', AIITITLE = RecordsGallery1.Selected.AIITITLE && Rater = User().Email )), 
    	Patch('YourListName', 
    		Defaults('YourListName'), 
    			{ 
    				AIITITLE: RecordsGallery1.Selected.AIITITLE, 
    				Rater: User().Email, 
    				'创新性': Rating2.Value 
    			} 
    	), 
    	UpdateIf('YourListName', 
    		AIITITLE = RecordsGallery1.Selected.AIITITLE && 
    		Rater = User().Email, 
    		{ '创新性': Rating2.Value } 
    		) 
    )
    
    //Replace YouListName with your SharePoint list name and correct the column name if it's wrong
     
    Note: If this column type is AIITITL.Value refer like this in patch and filter

    The key change is using RecordsGallery1.Selected.AIITITLE instead of RecordsGallery1.Selected. This ensures you're passing the correct field value instead of the entire record.

     

    If this response resolves your issue, please mark it as the Verified Answer so it can help other community members as well.
    ---------------------------------------------------------------------------------
     
    📩 Need more help? Mention @Kalathiya anytime!
    ✔️ Don’t forget to Accept as Solution if this guidance worked for you.
    💛 Your Like motivates me to keep helping!
  • Haque Profile Picture
    3,653 on at
    Hi @GGG666,
     
    Was folloing up on how did you overcome this?
  • GGG666 Profile Picture
    190 on at
    Hi  @Kalathiya 
     
    Thanks a lot for your help.
     
    Though,these code can not update items but created a new one.
    Would you please help on it ?
     
    Thanks
  • Kalathiya Profile Picture
    2,456 Super User 2026 Season 1 on at
    Hello @GGG666,
     
    Thanks, Updated code: 
     
    Assuming AIITLE column is lookup column.
    Set(
        varExistingRating,
        LookUp(
            'YourListName',
            AIITITLE.Id = RecordsGallery1.Selected.ID && Rater.Email = User().Email
        )
    );
    
    //Create new rating or update existing
    If(
        IsBlank(varExistingRating),
        Patch(
            'YourListName',
            Defaults('YourListName'),
            {
                AIITITLE: {
                    Id: RecordsGallery1.Selected.ID,        
                    Value: RecordsGallery1.Selected.ID
                },
                Rater: User(),                              
                '创新性': Rating2.Value                       
            }
        ),
        
        Patch(
            'YourListName',
            varExistingRating,
            {
                '创新性': Rating2.Value
            }
        )
    )
     
     
    If this response resolves your issue, please mark it as the Verified Answer so it can help other community members as well.

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

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 424

#2
WarrenBelz Profile Picture

WarrenBelz 355 Most Valuable Professional

#3
11manish Profile Picture

11manish 290

Last 30 days Overall leaderboard