Identifying Screen Mode in Client Side API

By | March 18, 2016

In our earlier posts, we had explained number of Sage CRM Client Side techniques that can be used to customize Sage CRM Screens, Grids, and Fields etc. In this blog, we will explain how to identify the mode of the screen using Client side API method.

New Stuff: Display Custom Tool tips in Calendar Tab

The two basic modes that we can identify using Client Side code are View and Edit mode. Sometimes we come across the scenario of hiding the field or performing some action on View mode (onload of page) or in edit mode of the screen.

In Sage CRM v7.1sp2 and earlier, we use the method getElementById to detect mode in Client Side code. Refer the sample code below.
<SCRIPT>
if (window.addEventListener)
window.addEventListener(“load”, ScreenMode, false)
if (window.attachEvent)
window.attachEvent(“onload”, ScreenMode)
function ScreenMode ()
{
var e=document.getElementById(“comp_name”);
if(e)
{
//Mode is edit
else
{
//Mode is view
}
}
</SCRIPT>

Now with the introduction of new client side API things have become fairly simple if you are using Javascript or JQuery functions in your program.

Sage CRM 7.2 Client Side API offers a method to identify the mode of the screen. All we need to do is write a simple code on the custom content of the screen to identify the mode of the screen. Refer the below code.

<SCRIPT>
crm.ready(function()
{
var sMode = crm.fields(“comp_name”).getMode();
if (sMode ==”edit”)
{
crm.infoMessage(sMode);
//’handle your operation in edit mode
}
else
{
crm.infoMessage(sMode);
//’handle your operation in edit mode
}
}
</SCRIPT>

Screenshot 1: Edit Mode Screen
Edit

Screenshot 2: View Mode Screen

View

In the above sample code snippet we are considering Company Screen as example and the field name comp_name as the identifying field factor to identify the mode. Similarly you can use other field as example, but ensure the field does exist on the screen.

About Us
Greytrix a globally recognized Premier Sage Gold Development Partner is a one stop solution provider for Sage ERP and Sage CRM needs. Being recognized and rewarded for multi-man years of experience, we bring complete end-to-end assistance for your technical consultations, product customizations, data migration, system integrations, third party add-on development and implementation expertise.

Greytrix has some unique integration solutions for Sage CRM with Sage ERPs (Sage Enterprise Management (Sage X3), Sage Intacct, Sage 100Sage 500 and Sage 300).We also offer best-in-class Sage ERP and Sage CRM customization and development services to Business Partners, End Users and Sage PSG worldwide. Greytrix helps in migrating of Sage CRM from Salesforce | ACT! | SalesLogix | Goldmine | Sugar CRM | Maximizer. Our Sage CRM Product Suite includes Greytrix Business Manager, Sage CRM Project Manager, Sage CRM Resource Planner, Sage CRM Contract Manager, Sage CRM Event Manager, Sage CRM Budget Planner, Gmail Integration, Sage CRM Mobile Service Signature and Sage CRM CTI Framework.

Greytrix is a recognized Sage Rockstar ISV Partner for GUMU™ Sage Enterprise Management – Sage CRM integration also listed on Sage Marketplace.

For more information on our integration solutions, please contact us at sage@greytrix.com. We will be glad to assist you.