RE: How to get Entity Name or ID from Entity View in MS Dynamics CRM ?
Hi Chhaya,
I'll slightly extend Nitin Verma's reply.
You can either have a Home Page context or a Form context.
Depends on the invocation location you can pass SelectedControl (would work on Home Page) and PrimaryControl (would work on the Form) into JS and in the script there should be two arguments in the function like OnLoad(formContext, homePageContext).
When the function will be called out, one of two arguments would not be null so you would need to validate it and use not null one further.
Some useful details are there in ms docs.
Regards,
Oleksandr