SMQL MY Function
You can use the MY function to retrieve fields defined by the current user, either in the relevant User (io_user) or User Preference (io_user_parameter) record. For example, you can query object_a with default_language=MY to return all records of object_a with a default_language field value that matches the same value in the current user’s User Preference record.
Format
MY(field_full_identifier)
* 
The field_full_identifier value you specify must exist in the io_user or io_user_parameter object. If the full identifier exists in both objects, the io_user field value is used in queries.
Parameter Name
Description
Example
field_full_identifier
A field in the User or User Preference record for the currently logged-in user.
io_username, io_default_language, io_default_time_zone, io_first_name, io_last_name
Result
Returns all records that match the specified field value for the currently logged-in user. For example, object_owner_last_name=MY(‘io_last_name’) returns all records that have the same object_owner_last_name field value as the currently logged-in user. If the current user’s family name is Woods, all records owned by users with the same last name are returned.
Example
To work with this example, import the Database class.
import com.servicemax.core.Database;
This example is for a Job object that has a svmx_country field with the String data type, and a User Preference object that has a similar field, core_user_country, which contains the country for the currently logged-in user, whose core_user_country value was previously set to UK.
def records = Database.query("select * from svmx_job where svmx_country = MY('core_user_country')");
def record = records.get(0);
record.svmx_country // this is in the example UK.
For more information:
Was this helpful?