Client Scripts Questions
Implement client-side scripting for form customization and improved user experience. Master g_form, g_user, and g_list APIs for dynamic form behavior.
Newest question added: AI-assisted drafts, not yet individually reviewedHow questions are made
About Client Scripts
Client Scripts run in the user's web browser and allow developers to customize form behavior dynamically. They respond to user actions like loading a form, changing a field, or submitting a record. The g_form API provides methods to manipulate form fields, while g_user gives access to the current user's information.
Why This Matters for Your Exam
Questions test your knowledge of different client script types, the g_form API, and when to use client scripts vs UI policies. Understanding the client-side context and its limitations is crucial.
Key Concepts to Master
Master the four client script types: onLoad (form display), onChange (field value change), onSubmit (form submission), and onCellEdit (list editing). Know the g_form API methods for showing/hiding fields, setting values, and making fields mandatory.
Exam Tips
Remember that client scripts run in the browser so they cannot use server-side APIs like GlideRecord directly — use GlideAjax instead. Know that onChange scripts receive control, oldValue, newValue, and isLoading parameters. The isLoading parameter helps prevent unwanted execution during form load.
Practice Questions
21 questions availableA developer creating a new client script opens the Type field to choose when the script should run. Which of these values is NOT one of the client script types?
👆 Click an option above to select your answer
Show answer and explanation
Correct answer: C. onBefore
The client script Type field offers onLoad(), onSubmit(), onChange(), and onCellEdit(). There is no onBefore type; Before is a business rule timing option that runs on the server before a database operation, so it is easy to confuse but does not apply to client scripts.
- Why A is wrong: onSubmit is a valid type. It runs when a form is submitted, typically to validate content, and it can cancel the submission by returning false.
- Why B is wrong: onLoad is a valid type. It runs when the system first renders the form and before users can enter data, typically to manipulate the form or set default values.
- Why D is wrong: onChange is a valid type. It runs when a particular field value changes on the form and receives parameters such as control, oldValue, newValue, and isLoading.
A developer writes an onChange client script that hides the Subcategory field when Category changes on the Incident form. Where does this script's JavaScript run?
👆 Click an option above to select your answer
Show answer and explanation
Correct answer: A. In the user's web browser
Client scripts let the system run JavaScript on the client, meaning the web browser, when client-based events occur such as a form loading, a form being submitted, or a field value changing. That is why they are used to hide fields or change values while the user works on the form.
- Why B is wrong: Server-side logic such as business rules runs on the instance server. Client scripts are defined to run in the web browser when form events happen.
- Why C is wrong: Client scripts do not run in the database. The docs describe them as JavaScript executed on the client (web browser) in response to form events.
- Why D is wrong: A MID Server is a Java application on the local network that moves data between the instance and external systems; it does not run form client scripts.