Door ID + Space ID

Can anyone tell me how to have the Door and Window ID automatically generate using the Space number as its reference?