What does the method getControl do exactly. Please someone explain with an example getControl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2016 05:41 AM
Example
if (!g_form.getControl('location'))
return;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2016 05:47 AM
It's similar to document.getElementById('id'). It gets the element with the field name you specify (not an id).
It's important for fields like Reference fields which are actually made up of several different input fields in the DOM (one for the sys_id, one for the display value, etc).
getControl() knows which input element to get.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-27-2016 06:14 AM
As sage said, it will execute like that.
One more information on getControl() was it was depreciated method for mobile.,It returns the the html field of element.
hasFiled() also same functionality of getControl().
hasFiled() - executes in both mobile and desktop. But getControl() - executes in desktop only.
for ex: (BP) Set Location to User refer this on incident form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2016 08:54 AM
Hi Balaji,
I have this code to display ghost text in the record producer, this is working for ESS view as we have getControl method the functionality is not working in Service Portal (as this method have been deprecated for the mobile platform and service portal).
I tried using g_form.hasField which did not work.
function onLoad() {
var name = g_form.getControl('u_application_name');
if(name !== null)
name.placeholder = "Common name for the application";
}
Can you help me in achieving this functionality.
Regards,
Bargavi.