Sage CRM Screens can exist in different ‘Modes’. The basic two modes that we have to worry about in Client Side code are View and Edit.

We can use the fact that in Sage CRM <INPUT> HTML tags are named and have an ID with same name as the physical field in the database. e.g. <input name=comp_name id=comp_name>. And these are only written into the page when the screen is in Edit Mode. If the <input> tag for a field exists then the page is in Edit mode and if it doesn't then it is in View mode.

In Sage CRM Client Side API has a method of checking mode. 

[code language="javascript"]
<SCRIPT>
//Detect Mode in Company Screen
crm.ready(function()
{
var strMode = crm.fields("comp_name").getMode();
if (strMode=="edit")
{
crm.infoMessage(strMode);
crm.fields("comp_status").collapse();
}
else
{
crm.infoMessage(strMode);
crm.fields("comp_status").show();
}
})
</SCRIPT>
[/code]