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 / Create SP Item if New,...
Power Apps
Answered

Create SP Item if New, Edit if Existing

(1) ShareShare
ReportReport
Posted on by 82

Hello,

I have a gallery that is powered by a distinct Excel list of transaction numbers. I am trying to enable users to click on the arrow in a gallery item to take them to a form (although a drop down would also work). If the selected gallery item already exists in another SharePoint list, I want it to take them to edit the existing record. If it does not already exist, I want the form to pre-populate with the transaction number in one of the fields.

 

The current code I have for the right arrow button in the gallery is:

Set(recordID, LookUp('Data Source','SP List Column Name','Excel Data Source Column Name'));
If(IsBlank(recordID),NewForm(Form Name), EditForm(Form Name));
Navigate(Screen Name);

 

I am receiving an error that is an invalid argument type (text) and it is expecting boolean instead.

 

I also setting the form item property = recordID.

 

Any help with this error would be greatly appreciated. Thank you!

Categories:
I have the same question (0)
  • poweractivate Profile Picture
    11,078 Most Valuable Professional on at

    @mglemser 

     

    Try If(recordID = Blank(),NewForm(Form Name), EditForm(Form Name));

     

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

    .. To test specifically for a blank value use if( Value = Blank(), ... instead of IsBlank.

     


     

    See if it works or if it gives more helpful error message.

     

    Also double check this part:

    Set(recordID, LookUp('Data Source','SP List Column Name','Excel Data Source Column Name'));

     

    Make sure everything is right there.

     

     

     

  • mglemser Profile Picture
    82 on at

    Thank you for your response. I made your suggested updates and also changed the first line of code but am still receiving an error on the equal sign in the second line of code saying "Incompatible types for comparison. These types can't be compared: Record, ObjNull". 

     

    Current Code: 

    Set(recordID, LookUp('SP List','SP List Column'=ThisItem.Result));
    If(recordID = Blank(),NewForm(Form Name), EditForm(Form Name));
    Navigate(Screen Name);

  • Verified answer
    AJ_Z Profile Picture
    3,711 Super User 2024 Season 1 on at

    This part would be the problem just so i understand is the gallery the same datasource as the one referenced in the lookup:
    problem:


    Set(recordID, LookUp('Data Source','SP List Column Name','Excel Data Source Column Name'))

    also in the Default
    Mode change it to: If(IsBlank(recordID),FormMode.New,FormMode.Edit)

  • shoog Profile Picture
    2,164 on at

    The problem is in your LookUp function. The second argument should not be a column name, but a function with boolean output to determine what record you want to return.

    You would typically do something like 'SP List Column Name'.ID = 'Excel Data Source Column Name'.ID

  • AJ_Z Profile Picture
    3,711 Super User 2024 Season 1 on at

    yes that would be the issue for him but presumably part of the lookup would reference the gallery.selected aswell.

  • mglemser Profile Picture
    82 on at

    Thank you for the response. Like you suggested, I think I am still having an issue with the "Set" line of code. The gallery is populated from the Excel file and I want to lookup the selected item against the SharePoint list to see if it exists. I updated my code above to fix the SP Column reference but am not sure what to do for the Excel column reference as both of the below versions still return the same error. 

     

    Set(recordID, LookUp('SP List','SP List Column'=ThisItem.Result));
    If(recordID = Blank(),NewForm(Form Name), EditForm(Form Name));
    Navigate(Screen Name);

     

    or

     

    Set(recordID, LookUp('SP List','SP List Column'=Excel Table.ColumnName));
    If(recordID = Blank(),NewForm(Form Name), EditForm(Form Name));
    Navigate(Screen Name);

     

    or

     

    Set(recordID, LookUp('SP List','SP List Column'='SP List Column Name'.ID = 'Excel Data Source Column Name'.ID));
    If(recordID = Blank(),NewForm(Form Name), EditForm(Form Name));
    Navigate(Screen Name);

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 345 Most Valuable Professional

#2
11manish Profile Picture

11manish 207 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 177

Last 30 days Overall leaderboard