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 / Lookup and Disable New...
Power Apps
Unanswered

Lookup and Disable New record if exists

(0) ShareShare
ReportReport
Posted on by 49

We have a Power App that is tied to a SharePoint list. There is a Text Input filed to record the Work Order Number, a drop down selector to select the Machine the record should be assigned to, a button for Start Batch and a button for Complete Batch. The are a dozen other button that on select increment integer by one. The basic concept of the app is to be able to record errors by pressing a button and thus incrementing by one each time. At the end the user presses Complete Batch button and all variables that have been incremented patch to the list record with the value recorded. We have an issue where users are entering duplicate work order numbers and thus creating duplicate information in the list that is throwing off reporting. We thought a method to control this would be to load the record into edit mode and give the user the opportunity to edit it again if the Work Order number entered is the same as an existing record.  We figure by doing this we would disallow creating duplicate records. Some functionality that we want as well is to throw a waring when a duplicate Work Order Number is used. 

 

I'm not sure the method to create this added functionality but thinking something along the lines of a lookup against Work Order Number. Our current app creates a new record upon pressing Start Batch button and patches every time a variable is changed (ie. Button press and integer incremented) so the record is readily available. Not sure how to code for this or even approach the solution. Any help would be appreciated!

 

Categories:
I have the same question (0)
  • Rajkumar_M Profile Picture
    3,747 Moderator on at

    Hi @serviceflow2 

     

    Check for Duplicate Work Order Number: Before creating a new record when the "Start Batch" button is pressed, you can use the LookUp function to check if a record with the entered work order number already exists in the SharePoint list.

     

    Display Warning for Duplicate: If a duplicate is found, you can display a warning message to the user and prevent the creation of a new record or guide them to edit the existing record.

     

    Edit Existing Record: If the user needs to edit the existing record, you can set the context of the form to edit mode and load the existing record for modification.

     

    This code should be placed on the OnSelect property of the "Start Batch" button

    Retrieve the entered work order number from the text input

    Set(varWorkOrderNumber, TextInput_WorkOrderNumber.Text);

    // Check if a record with the same work order number already exists

    If(
    IsEmpty(LookUp(SharePointListName, WorkOrderNumberColumn = varWorkOrderNumber)),

    // If no duplicate is found, create a new record or proceed with the current logic

    NewForm(FormName); // Replace with your logic to create a new record

    Navigate(ScreenName, ScreenTransition.None); // Navigate to the form screen if necessary

    // If a duplicate is found, display a warning and load the existing record for editing

    Set(varDuplicateWarning, true); // Set a variable to true to indicate a duplicate warning

    EditForm(FormName); // Set the form mode to edit
    Navigate(ScreenName, ScreenTransition.None); // Navigate to the form screen if necessary

    // Load the existing record into the form for editing
    Set(varRecordToEdit, LookUp(SharePointListName, WorkOrderNumberColumn = varWorkOrderNumber));

    FormName.Item = varRecordToEdit;

    )

     You can use the varDuplicateWarning variable to show or hide a warning label on the screen

     

    Thanks!

     

    If my response has been helpful in resolving your issue, I kindly request that you consider clicking "Accept as solution" and "giving it a thumbs up" as a token of appreciation.

     

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 416 Most Valuable Professional

#2
11manish Profile Picture

11manish 205 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 128 Super User 2026 Season 2

Last 30 days Overall leaderboard