It's possible.
Depending on the language and implementation of cucumber you're using, how you do it will vary, but assuming the process you're looking at is all inside one test, it will go something like this:
- Enter details into the page
- Read the unique number from the page (it should be stored in a local variable of some flavor)
- Go to the next page
- Enter the number in the local variable into the search field
- Continue your test.
That said, this kind of workflow is getting rather complicated for UI level testing. Personally, since this seems to be a case of creating a record then searching for that record, I'd look at taking a different approach:
- Test 1 - create the record and verify that a new unique identifier is generated.
- Test 2 - search for an existing record with a known identifier and verify that you get the expected result.
To use this structure you will need to be sure you have a database that you control, but it makes for simpler - and therefore less fragile - tests.