Vancouver - Server side Scripting Flashcards
After Business Rules execute their logic _ after a database operation occurs and before the resulting form is rendered for the user. Use after Business Rules when __ ___ are needed to the record being accessed in the database.
After Business Rules execute their logic immediately after a database operation occurs and before the resulting form is rendered for the user. Use after Business Rules when no changes are needed to the record being accessed in the database.
For example use _ Business Rules to invoke web services through the REST API. Service level agreement (SLA) calculations are also typically done as _ Business Rules.
For example use async Business Rules to invoke web services through the REST API. Service level agreement (SLA) calculations are also typically done as async Business Rules.
_ Business Rules execute their logic when a form loads and a record is loaded from the database. They must complete execution before control of the form is given to a user. The purpose of a _ Business Rule is to populate an automatically instantiated object, _ The object is passed from the _ Business Rule to the client-side for use by client-side scripts. Recall that when scripting on the client-side, scripts only have access to fields and field values for fields on the form and not all of the fields from the database. Use the _ object to pass data to the client-side without modifying the form. The _ object has no default properties.
Display Business Rules execute their logic when a form loads and a record is loaded from the database. They must complete execution before control of the form is given to a user. The purpose of a display Business Rule is to populate an automatically instantiated object, g_scratchpad. The g_scratchpad object is passed from the display Business Rule to the client-side for use by client-side scripts. Recall that when scripting on the client-side, scripts only have access to fields and field values for fields on the form and not all of the fields from the database. Use the g_scratchpad object to pass data to the client-side without modifying the form. The g_scratchpad object has no default properties.
Business Rule Actions are a configurable way to:
_
_
_
Business Rule Actions are a configurable way to:
Set field values
Add a message to a form
Abort the Business Rule execution
The ___ ___ option stops execution of the Business Rule and aborts the database operation. When the ___ ___ option is selected, you can use the Add Message option to print a message to the screen but no other options are available. Use this option when the script logic determines the database operation should not be performed.
The Abort action option stops execution of the Business Rule and aborts the database operation. When the Abort action option is selected, you can use the Add Message option to print a message to the screen but no other options are available. Use this option when the script logic determines the database operation should not be performed.
This is ___ syntax for a condition script:
current.short_description == “Hello world”
This is CORRECT syntax for a condition script:
current.short_description == “Hello world”
This is ___ syntax for a condition script:
if(current.short_description == “Hello world”){}
This is INCORRECT syntax for a condition script:
if(current.short_description == “Hello world”){}
Some example condition scripts:
The value of the State field changed from anything else to 6:
current.state.changesTo(6)
The Short description field has a value:
!current.short_description.nil()
The value of the Short description field is different than when the record was loaded:
current.short_description != previous.short_description
These are all correct ways to write a condition script
When scripting, use dot-walking to retrieve or set field values on related records. The syntax is:
<___>.<___>.<___>
For example:
if(current.u_requested_for.email == “beth.anglin@example.com”){
//logic here
}
When scripting, use dot-walking to retrieve or set field values on related records. The syntax is:
<object>.<related_object>.<field_name>
For example:
if(current.u_requested_for.email == "beth.anglin@example.com"){
//logic here
}
</field_name></related_object></object>
What does API stand for
Application Programming Interface
To use methods from the GlideSystem class, use the gs object:
To use methods from the GlideSystem class, use the gs object:
gs.<method></method>
What are the following:
Numbers: =, !=, >, >=, <, <=
Strings: =, !=, STARTSWITH, ENDSWITH, CONTAINS, DOES NOT CONTAIN, IN, NOT IN, INSTANCEOF
Use the addQuery() method to add query conditions. The addQuery operators are:
Numbers: =, !=, >, >=, <, <=
Strings: =, !=, STARTSWITH, ENDSWITH, CONTAINS, DOES NOT CONTAIN, IN, NOT IN, INSTANCEOF
The next() method along with what iterates through all returned records to process script logic?
The next() method and a while loop iterates through all returned records to process script logic:
// iterate through all records in the GlideRecord and set the Priority field value to 4 (low priority).
// update the record in the database
while(myObj.next()){
myObj.priority = 4;
myObj.update();
}
The next() method along with what processes only the first record returned
The next() method and an if processes only the first record returned.
// Set the Priority field value to 4 (low priority) for the first record in the GlideRecord
// update the record in the database
if(myObj.next()){
myObj.priority = 4;
myObj.update();
}
How do you update all the records processed by a glide record. What is the other caveot when using the method?
Use the updateMultiple() method to update all records in a GlideRecord. To ensure expected results with the updateMultiple() method, set field values with the the setValue() method rather than direct assignment.
// When using updateMultiple(), use the setValue() method.
// Using myObj.priority = 4 may return unexpected results.
myObj.setValue(‘priority’,4);
myObj.updateMultiple();
The GlideRecord API has a method for counting the number of records returned by a query: ___. Do not use the ___ method on a production instance as there could be a negative performance impact on the database. To determine the number of rows returned by a query on a production instance, use ___.
The GlideRecord API has a method for counting the number of records returned by a query: getRowCount(). Do not use the getRowCount() method on a production instance as there could be a negative performance impact on the database. To determine the number of rows returned by a query on a production instance, use GlideAggregate.
Where will the following message be displayed?
gs.error(“The value of the Short description field is “ + short_description);
gs.error(“The value of the Short description field is “ + short_description);
To view the log messages, use the All menu to open System Logs > System Log > Application Logs.
The scoped GlideSystem API has logging methods:
1._
2._
3._
4._(must be enabled)
The scoped GlideSystem API has logging methods:
gs.info()
gs.warn()
gs.error()
gs.debug() (must be enabled)
These can all be seen in the application log, though the gs.debug must be enabled first