Hi Vignesh Thirunavukkarasu,
You can create form extension class using [ExtensionOf] attribute. There you can declare form level variables https://docs.microsoft.com/en-us/dynamics365/unified-operations/dev-itpro/extensibility/class-extensions and use them later on in methods wrapped by chain of command docs.microsoft.com/.../method-wrapping-coc