Use the GET-parameters for creating links to a form with predefined field values. For example, the link {your-instance.uri}/record/itsm_incident?field_service=157416463016114934&field_company=157407729516040921 will redirect you to a new incident record where the Service and Company fields are already populated with the defined values.
User case
In this section we will dwell upon two cases of using the GET-parameters in URL.
GET-parameters in a UI-action
Case:
We need to create a UI-action button redirecting from related lists to a page with predefined values. We take the Table (sys_db_table) record form and Columns (sys_db_column) related list as an example.
To create a UI-action, perform the following steps:
- Navigate to System Settings → UI Actions.
Click New and fill in the fields:
Configurations and Actions tab Fields Value Table Column Show Update true Client true Script s_go.open('/record/sys_db_column?field_table_id=' + s_form.getUniqueValue() + '&form_view=Default'); Position and Style tab Use For Related Lists List Banner Button true - Click Save or Save and Exit to apply changes.
As result, the created button will redirect to the following page: https://{your-instance.uri}/record/sys_db_column?field_table_id=156076775207617405&form_view=Default. The system retrieves the GET-parameters and fills in the fields accordingly.
A good practice is to add the view parameter: &form_view=<form_view_name>. Thus, our example link will be: https://{your-instance.uri}/record/sys_db_column?field_table_id=156076775207617405&form_view=Default.
This will ensure that a particular user will see all the necessary fields no matter what view they prefer. See the Form Layout article to learn more.
GET-parameters in a script
Case:
We need to create a script that retrieves information from a phone call and inserts the corresponding values in an ITSM Task record.
To fulfill the task, perform the following steps:
- Navigate to System Settings → Client Script.
Click New and fill in the fields.
Type: onLoad Expand sourceif (s_form.isNewRecord()) { const currentUrl = new URL(window.location.href); const phoneNumberFromUrl = currentUrl.searchParams.get('phone_number'); if (phoneNumberFromUrl) { const employeeByPhone = new SimpleRecord('employee'); employeeByPhone.addQuery('business_phone', phoneNumberFromUrl); employeeByPhone.query(async () => { if (employeeByPhone.next()) { await s_form.setValue('caller', employeeByPhone.sys_id); s_form.setReadOnly('contact_type', true); s_form.showFieldMsg('caller', 'Searched by Business Phone', 'warning'); } }); } }
- Click Save or Save and Exit.
When a call is received, the system executes the script which retrieves the phone number and generates a link: https://{your-instance.uri}/record/itsm_task?field_contact_type=10&phone_number=77297742988. By following the link, a new ITSM Task record is created. As a result, the following fields are populated automatically:
Fields | Value |
---|---|
Contact Type | Phone (value='10') |
Caller | Marco Polo |
The system populates the Caller field when the script finds a record from the Employee table with the corresponding phone number (in our case, it is 77297742988). That is, the script found that employee Marco Polo has this phone number in phone_number field in his record.
Use the GET-parameters for creating links to a form with predefined field values. For example, the link {your-instance.uri}/record/itsm_incident?field_service=157416463016114934&field_company=157407729516040921 will redirect you to a new incident record where the Service and Company fields are already populated with the defined values.
User case
In this section we will dwell upon two cases of using the GET-parameters in URL.
GET-parameters in a UI-action
Case:
We need to create a UI-action button redirecting from related lists to a page with predefined values. We take the Table (sys_db_table) record form and Columns (sys_db_column) related list as an example.
To create a UI-action, perform the following steps:
- Navigate to System Settings → UI Actions.
Click New and fill in the fields:
Configurations and Actions tab Fields Value Table Column Show Update true Client true Script s_go.open('/record/sys_db_column?field_table_id=' + s_form.getUniqueValue() + '&form_view=Default'); Position and Style tab Use For Related Lists List Banner Button true - Click Save or Save and Exit to apply changes.
As result, the created button will redirect to the following page: https://{your-instance.uri}/record/sys_db_column?field_table_id=156076775207617405&form_view=Default. The system retrieves the GET-parameters and fills in the fields accordingly.
A good practice is to add the view parameter: &form_view=<form_view_name>. Thus, our example link will be: https://{your-instance.uri}/record/sys_db_column?field_table_id=156076775207617405&form_view=Default.
This will ensure that a particular user will see all the necessary fields no matter what view they prefer. See the Form Layout article to learn more.
GET-parameters in a script
Case:
We need to create a script that retrieves information from a phone call and inserts the corresponding values in an ITSM Task record.
To fulfill the task, perform the following steps:
- Navigate to System Settings → Client Script.
Click New and fill in the fields.
Type: onLoad Expand sourceif (s_form.isNewRecord()) { const currentUrl = new URL(window.location.href); const phoneNumberFromUrl = currentUrl.searchParams.get('phone_number'); if (phoneNumberFromUrl) { const employeeByPhone = new SimpleRecord('employee'); employeeByPhone.addQuery('business_phone', phoneNumberFromUrl); employeeByPhone.query(async () => { if (employeeByPhone.next()) { await s_form.setValue('caller', employeeByPhone.sys_id); s_form.setReadOnly('contact_type', true); s_form.showFieldMsg('caller', 'Searched by Business Phone', 'warning'); } }); } }
- Click Save or Save and Exit.
When a call is received, the system executes the script which retrieves the phone number and generates a link: https://{your-instance.uri}/record/itsm_task?field_contact_type=10&phone_number=77297742988. By following the link, a new ITSM Task record is created. As a result, the following fields are populated automatically:
Fields | Value |
---|---|
Contact Type | Phone (value='10') |
Caller | Marco Polo |
The system populates the Caller field when the script finds a record from the Employee table with the corresponding phone number (in our case, it is 77297742988). That is, the script found that employee Marco Polo has this phone number in phone_number field in his record.
- No labels