Hi Darpan,
It seems like you are trying to show a page-specific field on every page on the site, would that be right?
The Options Page extension will help you here. This allows you to display a field on any page of the site, added into one site-wide options page. This is the opposite of adding fields to pages, that’ll only be accessible when the page is being shown; hence why when you added the post ID to your code, it worked.