Introduction
If the Tools4ever GitHub account doesn't contain an importable delegated form that does what you need, you can create a custom delegated form.
Create a custom delegated form
- Go to Delegation > Delegated Forms and click Create Delegated Form.
- Optionally, select an existing dynamic form to use as your template. For this example, we'll create a new form named
Weather report
. - Configure the delegated form (and design its template, if you didn't select an existing dynamic form). Refer to the documentation below on the General, Form, Groups, Categories, and Task tabs.
Configure a delegated form
General tab
- Name
The name of the form, shown in the Delegated Forms Overview. - Identifier
The URL slug used to access the form. Select the wand icon to automatically regenerate the slug based on the provided Name. - Dynamic Form
The dynamic form that is being used as the template for this delegated form, if any. - Enabled
Enable or disable this form. Disabled forms are not published to the HelloID User Dashboard. - Use FA Icon
Enable this toggle to choose a form icon from the Font Awesome library. Disable it to upload a custom image. The chosen icon or image is displayed to end users on this form's Servicedesk tile. - Icon
Pick an icon or upload an image, as determined by the Use FA Icon toggle. All uploaded images are resized to 64x64 px. For the best results, design and upload an icon that already has these dimensions. - Hide Summary
Enable to hide the form's final summary page from the end user.
Form tab
The Form tab lets you edit the form's template. For more information, see the form element reference and other form-related articles in the Self Service documentation.
For each element you create, you can optionally bind a data source to populate it.
For this example, we'll create a form with just one element - a required dropdown with the Labels Fahrenheit
and Celsius
, corresponding Values Fahrenheit
and Celsius
, and the Form Key tempUnitDropdown
.
Groups tab
Until you attach one or more user groups to a delegated form, no users will be able to access it. Once a group is attached to a delegated form, all users in the group will be able to access it. Note that you must have first enabled Servicedesk access.
To attach one or more groups, go to the Groups tab, and then enter the group(s) you wish to grant access to the delegated form. In this example, we'll add the Admins
and Users
groups.
Categories tab
The Categories tab lets you add this delegated form to one or more delegated form categories.
For this example, we'll use a General
category that we created separately.
Task tab
On the Task tab, you can create an inline PowerShell script to run on form submission.
For this example, we'll continue with the Weather report
delegated form that we created above.
Create an inline PowerShell script in a delegated form
An inline PowerShell script in a delegated form runs when an end user submits the form in the Servicedesk.
- Go to the form's Task tab.
- In the script editor, enter your PowerShell script. For this example, we'll use the following script:
$temperatureUnit = $($form.tempUnitDropdown) $locationEndpoint = "https://api.open-meteo.com/v1/forecast?latitude=40.71&longitude=-74.01&hourly=temperature_2m&temperature_unit=$temperatureUnit&windspeed_unit=mph&precipitation_unit=inch" Write-Information "Looking up New York weather" $response = Invoke-RestMethod -uri $locationEndpoint Write-Information "Response: $response" $result = @{weather = "Current time: $($response.hourly.time[0]); current temperature: $($response.hourly.temperature_2m[0]) degrees $temperatureUnit"} Write-Information "Result: $($result.weather)" $Log = @{ Action = "SendNotification" System = "DemoSystem" Message = "New York Weather fetched" IsError = $false } Write-Information -Tags "Audit" -MessageData $Log
The Run On Cloud Agent toggle determines whether the script is executed via your HelloID tenant's Cloud Agent (hosted by Tools4ever), or on a local server via an on-premises Agent (hosted by your organization). For this example, we'll use the cloud agent. - For the Input, enter the following test value. This simulates input from the form we designed on the Form tab.
{ "tempUnitDropdown": "celsius" }
- Click Execute PowerShell to test the script.
- Go to the Received Logs tab. The current New York weather has been fetched, in degrees Celsius.
- Go to the Received Audit Logs tab. The audit log message constructed in the script is displayed. In production, it is written into Elastic.
- Click Save to save the delegated form.
Return results
Delegated form tasks do not return any data to HelloID.
Task Logging
See Delegated form task logging.
Audit Logging
See Delegated form audit logging.
Send emails
Submissions tab
On the Submissions tab, you can view user submissions for this delegated form.
- Select the Open details link for the relevant submission to see additional information.
For more detailed logging, go to Activities - Overview.
Access a delegated form
A delegated form is visible to users who have the Servicedesk permission and are members of a group attached to the form. See the Servicedesk introduction for instructions on accessing a delegated form.