Skip Navigation LinksALVAO 8.2ALVAO Service DeskSystem Implementation in an OrganizationCustom Edits and ExtensionsCustom Form Skip Navigation Links. Skip Navigation Links Skip Navigation Links.


Custom New Request Submit Form

Custom forms can be used to customize the New Request Form within the Portal. A single custom form can create multiple requests simultaneously to support more complex business processes, such as the employment of a new employee.

Templates for creating custom forms are located in the \Custom\Templates\ folder under the ALVAO WebApp installation folder. The files NewTicket_Template.cshtml and NewTicket_Template.cs are provided as templates.

The .cshtml files define the form layout, the .cs files describe the behavior for submitting data.

Standard Templates List:

Name Description
Empty Empty template
NewTicket_CustomModel Using the custom data model
NewTicket_Template Creating multiple requests with mutual link
NewTicket_WorkTimeCost Displays a field for reporting the time and trip

Creating New Form

First, select a form template that is closest to the purpose of the form you are about to create. Copy the .cshtml file of the selected form to the Custom\<company name> folder and the .cs file to the Custom\<company name>\Code folder. Rename both files to reflect the function of the form. We recommend that the form name corresponds to the name of the service in which it will be used. Both files (.cshtml and .cs) need to have the same file name.

Warning:
Names of the forms used have to be unique.

Next you will have to adapt the form code to the new file names.

  • At the beginning of the .cs file, put behind the word namespace the name of the namespace Alvao.ServiceDesk.ServiceDeskWebApp.Custom.<company_name>. We recommend using a name that corresponds to the directory name.
  • Then open the .cs file, find the class keyword and replace the old file name with the new one. The class name has to be <name of cshtml page>Controller; for example, if the page is named NewTicket.cshtml, then the class name will be NewTicketController.

Form Layout Definition

The .cshtml file defines the form layout and specifies which form elements will be displayed. When the user sends the completed form, the data are converted to text which can be used in the behavior definitions.

In the .cshtml file, only edit the parts between the two lines <div id="CustomFormContent" and </div>. Only this part is used to convert form elements to text. Any elements outside CustomFormContent will be displayed in the form, but they will not be converted.

The following form elements are converted to text in requests:

Element name Conversion method Line break
<label> The displayed text will be included into the request body, followed by a colon. No
Editor "StringField" The request body will include the text that the user enters into the text box. If you add the „UniquedId = Model.TicketBodyGuid“ value into element parameter, you will be able to input the formatted text (HTML).
Note:
On one form there can be a maximum of one HTML format element.
Yes
Editor "BoolField" The displayed text will be included into the request body, followed by "Yes or No", based on the choice the user makes. Yes
Editor "DateTimeField" The request body will include the date selected by the user. Yes
Editor "DropDownListField" The request body will include the item selected by the user. Yes
Editor "RadioButtonList" The request body will include the item selected by the user. Yes
Editor "CheckBoxList" The request body will include a sequence of all items selected by the user. Yes
Editor "DoubleField" The request body will include integer or decimal number entered by the user. Yes
Editor "ColumnsControl" The request body will include a sequence of all displayed items. Values will be inserted directly to the properties of a request. Yes
Editor "AttachmentField" Attachments will be added to the request creating report. No

Any elements that are not included in the table above will not be included in the request body. You can find examples on how to use all of the individual elements in the NewTicket_Template.cshtml file.

Note:
Number format in the DoubleField is checked when submitting the form and if not correct, it is tagged in red and the message please specify number in the correct format is displayed.
The correct English format of writing decimal number is with decimal period.

Displaying articles from the knowledge base and current news

In the custom forms, you can display articles from the knowledge base and current news of the form service in the same manner as in the system new request submit form.

For displaying articles from the knowledge base and service current news in custom form add the following text to the end of the form:

@Html.Partial("_NewsAndKnowledgeBaseFAQ", Model.FAQModelWrapper, new ViewDataDictionary(){})

Form Behavior Definition

The form behavior is defined in the .cs file. The first part of the file code includes the area that can be edited. This area is marked with code comments. Do not alter any other parts of the code!

The creation of requests is the most important feature. The file already includes an example of a request creation that you can use to create your own request versions.

The basic request creation structure is as follows:

CreateTicket("Service Name", "Request Subject", "Request Body Text\n" + TicketBody);

Where TicketBody is the default request body text that has been created through the conversion of the form data to text. If required, you can combine the texts as shown in the example. If you want to insert a line break, use the \n tag.

Note:
If the "StringField" element, into which you can enter text in HTML format, is used in the form, use the "<br>" string for line break.

The Service Name has to be filled in exactly as displayed in the Admin program. Subservices can be divided with the / character, e.g. "Internal/HR/New Employee". You have to enter the entire path from the root folder.

You can also use the advanced create request command version which also includes the create bindings feature:

CreateTicket("Service Name", "Request Subject", "Custom Request Body Text\n" + TicketBody, MainTicketId, TicketRelationType. SystemTicketRelationType.IsChildOf);

Where MainTicketId is the number of the linked request. An example of retrieving the ID from the main request is included in the template. The value TicketRelationType.SystemTicketRelationType.IsTheChildOf defines the link types:

Value Link Type
RelatesTo Relates to
IsParentOf Is parent of
IsChildOf Is child of
PrecedesBefore Precedes before
FollowsAfter Follows after
Blocks Blocks
IsBlockedBy Is blocked by
IsDuplicatedBy Is duplicated by
Duplicates Duplicates

For example, in the case of the value TicketRelationType.SystemTicketRelationType.IsChildOf the request that is being created will be a child of the request and the request with the number retrieved through MainTicketId will be a parent.

Use the following structure for access to the custom items values (example for items "NewName" and "NewNumber"):

string NewName = ((ColumnsControl)Model.ColumnsControl["ColumnsControl0"]).Values.Find(Col => Col.Column.sColumn == "NewName").Value as string;
int NewNumber = (int)((ColumnsControl)Model.ColumnsControl["ColumnsControl0"]).Values.Find(Col => Col.Column.sColumn == "NewNumber").Value;

Connecting the Form to Application

If you go to the service settings and enter the path to the form, this form will be displayed in the ALVAO WebApp instead of the default new request form. Please refer to Service Desk Settings for more information.

The form path has to be specified in a form, such as e.g. ~/Custom/<company name>/NewTicket_Template. Entering the .cshtml file extension is not allowed.

Dynamic Switching of Form Languages

When editing the .cs and .cshtml files, you can use the .resx files containing localized strings for individual languages. These strings are displayed to each user loaded from the file according to the user's preferred language. If the .resx file has not been created for any language, the .resx file for English will be used.

Creating the .resx File for Language

First we create a .resx file for English. From the Custom\Templates\Resources folder copy the SampleController.resx file into the Custom\<company name>\Resources folder and rename it to <cshtml page name>Controller.resx.

Open this file in text editor. Insert the following lines behind the "<!-- Insert --!>" line:

<data name="name" xml:space="preserve">
<value>Name</value>
</data>

The result should be the following:

<!-- Insert --!>
<data name="name" xml:space="preserve">
<value>Name</value>
</data>
<!-- Do not change --!>
</root>

Lines:

<data name="name" xml:space="preserve">
<value>Name</value>
</data>

can be copied again and edited in the manner they create more localized strings. Every value "<data name="name" must be unique in the file.

<data name="name" specifies the name used as parameter in the GetResources() function which is described in Using .resx File in .cs and .cshtml Files. <value>Name</value> specifies the value returned by this function.

Lets create the .resx file for Czech language. Copy the edited <cshtml page name>Controller.resx file into the same folder and rename it <cshtml page name>Controller.cs.resx. Edit the copy of the <value>Name</value> item, so the following text is in the file:

<!-- Insert --!>
<data name="name" xml:space="preserve">
<value>Name</value>
</data>
<!-- Do not change --!>
</root>

Warning:
Do not edit the other parts of the resx files.

The files for other languages, which can be set as the user's preferred languages, can be copied and edited in the same manner as the <cshtml page name>Controller.cs.resx file. These files are always named <cshtml page name>Controller.<language abbreviation>.resx (for example, <cshtml page name>Controller.de.resx). The usable language abbreviations are defined here:

http://msdn.microsoft.com/cs-cz/goglobal/bb896001.aspx

Using .resx File in .cs and .cshtml Files

The individual items created in .resx files can be used also in .cs and .cshtml files.

In .cshtml file use the label = Model.GetResource("name") string instead of label = "Name" string. The user with Czech set as a preferred language, will see the field description Jméno. Other users will see Name.

When using .cs file, the same function could be achieved by GetResource("name") function instead of a string.

 

Did not find what you were looking for? Ask our technical support team.