Video blog: Number Sequence & Serial Number Generation in Canvas App

To generate a serial number in collections there is no direct way to get it apart from sequence
code.

High level resolution steps

  • Make two collections and patch the code to a gallery
  • Use number sequence, first, last, forall codes

Detailed resolution steps

Step 1: In the onstart property of the app, give the below code:


ClearCollect( 
   Vehicles, 
    { 
        Year: 2016, 
        Make: "Hyundai", 
        Model: "i10" 
    }, 
    { 
        Year: 2016, 
        Make: "Hyundai", 
        Model: "i20" 
    }, 
    { 
        Year: 2016, 
        Make: "Hyundai", 
        Model: "i30" 
    }, 
    { 
        Year: 2017, 
        Make: "Toyota", 
        Model: "Camry" 
    }, 
    { 
        Year: 2018, 
        Make: "Toyota", 
        Model: "Fortuner" 
    }  
); 
ClearCollect( 
    rownumvehicles, 
    ForAll( 
        Sequence(CountRows(Vehicles)),
        Patch( 
          Last( 
            FirstN( 
               Vehicles, 
               Value 
            ) 
          ), 
          {Serialnum: Value} 
       ) 
     ) 
   )
    

Step 2: Add a gallery and give the items property as collection that you created from step 1 (rownumvehicles).

Canvas app gallery showing vehicle collection with serial number, make, and model fields.

And give three text fields and provide the code as ThisItem.SerialNum, ThisItem.Make, ThisItem.Model.

Step 3: To Display 10 numbers starting from 100:
Give this Code in Dropdown – Items property = Sequence(100,1)

Display first 10 Even numbers :
Give this Code in Dropdown – Items property = Sequence(10,2,2)

Display next 7 dates from Today:
Give this Code in Dropdown – Items property = ForAll(Sequence(7),Today()+Value)

Display all the dates for the month of Text input in the year 2024:
Give this Code in Dropdown – Items property = ForAll(Sequence(31),Date(2024,TextInput2.Text,Value)) TextInput2.text will be text input field.

Dropdown in PowerApps displaying sequence generation with code for date display and number sequence options.