In "Add New" button page, how to get data from the collection itself and put some kind of formula?

I have Task collections with Task ID which handles Mechanical and Electrical works. Both sections have different ID prefix for example, for mechanical, M001 and Electrical , E001.

So I want if we press the “Add New” button, and depends on which section is selected, it will auto-fill with the “prefix” + " Previous Number + 1)

Please provide screenshots to illustrate your issue, as this will help us understand it better.