This is pretty easy to do using the SharePoint list id and a double submit.
You will need the following:
- Field in your main data source called "key" that is promoted
- Submit data connection to your form library
- Retrieve data connection to the same form library with the "key" column checked
Add a rule to do the following when a button is clicked (or some other event):
- Add an action that sets your "key" field using the function concat(now()," - ", userName())
Add a condition to only do this once if the field is blank
Add another rule to get the SharePoint ID:
- Add an action that submits your form to your SharePoint library
- Add an action that sets the "key" field under the Retrieve data connection's query section
- Add an action that queries the library
- Add an action that sets the ID field based on the ID for the returned record.
- Add an action that submits it to the SharePoint library again
There you have it.