input
stringlengths 14
1.47k
| output
stringlengths 286
299k
| instruction
stringclasses 1
value |
---|---|---|
Add Validations to an Inline Editable Grid
Allows the user to change data directly in a grid, and validate a various entries.
This design pattern is not recommended for offline interfaces because reflecting immediate changes in an interface based on user interaction requires a connection to the server.
In this case, the recipe validates for a relevant phone number standard as well as non-sensical dates for existing employees.
Change an employee's phoneNumber to a value greater than 12 digits. Notice that the validation message shows up when you move away from the field.
Change an existing employee's startDate to a date in the future. Notice that the validation message shows up when you move away from the field. Change the date back to a past date
Add a new employee. Change that new employee's startDate to a date in the future. Notice that the validation message does not show up when you move away from the field.
This scenario demonstrates:
How to configure validation messages that show up as soon as a condition is satisfied
How to configure validation messages to appear outside the component where the validation occurred
| a!localVariables(
/*
* local!employees is provided in this recipe as a way to start with hard-coded
* data. However, this data is identical to the data created from the entity-backed
* tutorial. Replace the hard-coded data with a query to the employee data store
* entity and all of the employee records from the tutorial will appear.
*
* To replace this data with your own, replace (ctrl+H or cmd+H) all references to
* local!employees with your data source, either via rule input or local variable.
*/
local!employees: {
a!map( id: 1, firstName: "John" , lastName: "Smith" , department: "Engineering" , title: "Director" , phoneNumber: "555-123-4567" , startDate: today()-360 ),
a!map( id: 2, firstName: "Michael" , lastName: "Johnson" , department: "Finance" , title: "Analyst" , phoneNumber: "555-987-6543" , startDate: today()-360 ),
a!map( id: 3, firstName: "Mary", lastName: "Reed" , department: "Engineering" , title: "Software Engineer" , phoneNumber: "555-456-0123" , startDate: today()-240 ),
},
a!formLayout(
label: "Add or Update Employee Data",
instructions: "Add, edit, or remove Employee data in an inline editable grid",
contents: {
a!gridLayout(
totalCount: count(local!employees),
headerCells: {
a!gridLayoutHeaderCell(label: "First Name" ),
a!gridLayoutHeaderCell(label: "Last Name" ),
a!gridLayoutHeaderCell(label: "Department" ),
a!gridLayoutHeaderCell(label: "Title" ),
a!gridLayoutHeaderCell(label: "Phone Number" ),
a!gridLayoutHeaderCell(label: "Start Date", align: "RIGHT" ),
/* For the "Remove" column */
a!gridLayoutHeaderCell(label: "" )
},
/* Only needed when some columns need to be narrow */
columnConfigs: {
a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:2 ),
a!gridLayoutColumnConfig(width: "ICON")
},
/*
* a!forEach() will take local!employee data and used that data to loop through an
* expression that creates each row.
*
* When modifying the recipe to work with your data, you only need to change:
* 1.) the number of fields in each row
* 2.) the types of fields for each column (i.e. a!textField() for text data elements)
* 3.) the fv!item elements. For example fv!item.firstName would change to fv!item.yourdata
*/
rows: a!forEach(
items: local!employees,
expression: a!gridRowLayout(
contents: {
/* For the First Name Column*/
a!textField(
/* Labels are not visible in grid cells but are necessary to meet accessibility requirements */
label: "first name " & fv!index,
value: fv!item.firstName,
saveInto: fv!item.firstName,
required: true
),
/* For the Last Name Column*/
a!textField(
label: "last name " & fv!index,
value: fv!item.lastName,
saveInto: fv!item.lastName,
required:true
),
/* For the Department Column*/
a!dropdownField(
label: "department " & fv!index,
placeholder: "-- Select -- ",
choiceLabels: { "Corporate", "Engineering", "Finance", "Human Resources", "Professional Services", "Sales" },
choiceValues: { "Corporate", "Engineering", "Finance", "Human Resources", "Professional Services", "Sales" },
value: fv!item.department,
saveInto: fv!item.department,
required:true
),
/* For the Title Column*/
a!textField(
label: "title " & fv!index,
value: fv!item.title,
saveInto: fv!item.title,
required:true
),
/* For the Phone Number Column*/
a!textField(
label: "phone number " & fv!index,
placeholder:"555-456-7890",
value: fv!item.phoneNumber,
saveInto: fv!item.phoneNumber,
validations: if( len(fv!item.phoneNumber) > 12, "Contains more than 12 characters. Please reenter phone number, and include only numbers and dashes", null )
),
/* For the Start Date Column*/
a!dateField(
label: "start date " & fv!index,
value: fv!item.startDate,
saveInto: fv!item.startDate,
required:true,
validations: if( and( isnull(fv!item.id) , todate(fv!item.startDate) < today() ), "This Employee cannot have a start date before today.", null),
align: "RIGHT"
),
/* For the Removal Column*/
a!richTextDisplayField(
value: a!richTextIcon(
icon: "close",
altText: "delete " & fv!index,
caption: "Remove " & fv!item.firstName & " " & fv!item.lastName,
link: a!dynamicLink(
value: fv!index,
saveInto: {
a!save(local!employees, remove(local!employees, save!value))
}
),
linkStyle: "STANDALONE",
color: "NEGATIVE"
)
)
},
id: fv!index
)
),
addRowlink: a!dynamicLink(
label: "Add Employee",
/*
* For your use case, set the value to a blank instance of your CDT using
* the type constructor, e.g. type!Employee(). Only specify the field
* if you want to give it a default value e.g. startDate: today()+1.
*/
value: {startDate: today() + 1},
saveInto: {
a!save(local!employees, append(local!employees, save!value))
}
),
/* This validation prevents existing employee start date from changing to a date in the future*/
validations: if(
a!forEach(
items: local!employees,
expression: and( not( isnull( fv!item.id)), todate(fv!item.startDate) > today() )
),
"Existing Employees cannot have an effective start date beyond today",
null
),
rowHeader: 1
)
},
buttons: a!buttonLayout(
primaryButtons: a!buttonWidget(
label: "Submit",
submit: true
)
)
)
)
Notable implementation details.
The array of validations can contain either text or a validation message created with a!validationMessage(). Use the latter when you want the validation message to show up when the user clicks a submit button, or a validating button.
| Solve the following leet code problem |
Problem
Enforce that the user enters at least a certain number of characters in their text field, and also enforce that it contains the "@" character.
This scenario demonstrates:
How to configure multiple validations for a single component
Type fewer than 5 characters and click "Submit".
When testing offline, the form queues for submission but returns the validation messages when you go back online and the form attempts to submit.
Type more than 5 characters but no "@" and click "Submit".
When testing offline, the form queues for submission but returns the validation messages when you go back online and the form attempts to submit.
Type more than 5 characters and include "@" and click "Submit".
|
a!localVariables(
local!varA,
a!formLayout(
label: "Example: Multiple Validation Rules on One Component",
contents:{
a!textField(
label: "Text",
instructions: "Enter at least 5 characters, and include the @ character",
value: local!varA,
saveInto: local!varA,
validations: {
if(len(local!varA)>=5, null, "Enter at least 5 characters"),
if(isnull(local!varA), null, if(find("@", local!varA)<>0, null, "You need an @ character!"))
}
)
},
buttons: a!buttonLayout(
primaryButtons: a!buttonWidget(
label: "Submit",
submit: true
)
)
)
)
| Solve the following leet code problem |
Add and Populate Sections Dynamically
Add and populate a dynamic number of sections, one for each item in a CDT array.
Each section contains an input for each field of the CDT. A new entry is added to the CDT array as the user is editing the last section to allow the user to quickly add new entries without extra clicks. Sections can be independently removed by clicking on a "Remove" button. In the example below, attempting to remove the last section simply blanks out the inputs. Your own use case may involve removing the last section altogether.
| a)
Fill in the first field and notice that a new section is added as you're typing.
Add a few sections and click on the Remove button to remove items from the array
Notable Implementation Details
fv!isLast is being used to populate the instructions of the last text field as well as prevent the remove button from appearing in the last section.
a!localVariables(
/* A section will be created for every label value array present */
local!records: {'type!{http://www.appian.com/ae/types/2009}LabelValue'()},
{
a!forEach(
items: local!records,
expression: a!sectionLayout(
label: "Section " & fv!index,
contents: {
a!textField(
label: "Label",
instructions: if(
fv!isLast,
"Value of local!records: "&local!records,
{}
),
value: fv!item.label,
saveInto: {
fv!item.label,
if(
fv!isLast,
/* This value appends a new section array to section*/
a!save(local!records, append(local!records, cast(typeof(local!records), null))),
{}
)
},
refreshAfter: "KEYPRESS"
),
a!textField(
label: "Value",
value: fv!item.value,
saveInto: fv!item.value,
refreshAfter: "KEYPRESS"
),
a!buttonArrayLayout(
a!buttonWidget(
label: "Remove",
value: fv!index,
saveInto: {
a!save(local!records, remove(local!records, fv!index))
},
showWhen:not( fv!isLast )
)
)
}
)
)
}
)
b)
Offline
Since sections cannot be added dynamically when offline, you should include multiple sections initially in case they are needed. To support this use case for offline, we will create a different expression with a different supporting rule.
There are now 3 sections available to the user immediately.
Fill out some of the sections but leave others blank and submit the form.
Notice that null values are removed from the array and only non-null values are saved.
a!localVariables(
/* A section will be created for every label value array present */
local!records: { repeat(3, 'type!{http://www.appian.com/ae/types/2009}LabelValue'()) },
{
a!forEach(
items: local!records,
expression: a!sectionLayout(
label: "Section " & fv!index,
contents: {
a!textField(
label: "Label",
instructions: if(
fv!isLast,
"Value of local!records: "&local!records,
{}
),
value: fv!item.label,
saveInto: {
fv!item.label,
},
refreshAfter: "KEYPRESS"
),
a!textField(
label: "Value",
value: fv!item.value,
saveInto: fv!item.value,
refreshAfter: "KEYPRESS"
)
}
)
)
}
)
| Solve the following leet code problem |
Add, Edit, and Remove Data in an Inline Editable Grid
Allow the user to change data directly in an inline editable grid
This scenario demonstrates:
How to use the grid layout component to build an inline editable grid
How to allow users to add and remove rows in the grid
How to pass in a default value initially and while adding a new row
Edit values in an existing row.
Click the Add Employee link to insert a new row into the editable grid. Add values to that row.
Delete a row by clicking on the red X at the end of a row. Notice the remaining rows will adjust automatically.
Notable implementation detailsCopy link to clipboard
The component in each cell has a label, but the label isn't displayed. Labels and instructions aren't rendered within a grid cell. It is useful to enter a label for expression readability, and to help identify which cell has an expression error since the label is displayed in the error message. Labels are also necessary to meet accessibility requirements, so that a screen reader can properly parse the grid.
To keep track of which items are removed so that you can execute the Delete from Data Store Entity smart service for the removed items, see the Track Adds and Deletes in an Inline Editable Grid recipe.
| a!localVariables(
/*
* local!employess is provided in this recipe as a way to start with hard-coded
* data. However, this data is identical to the data created from the entity-backed
* tutorial. Replace the hard-coded data with a query to the employee data store
* entity and all of the employee records from the tutorial will appear.
*
* To replace this data with your own, replace (ctrl+H or cmd+H) all references to
* local!employees with your data source, either via rule input or local variable.
*/
local!employees: {
a!map( id: 1, firstName: "John" , lastName: "Smith" , department: "Engineering" , title: "Director" , phoneNumber: "555-123-4567" , startDate: today()-360 ),
a!map( id: 2, firstName: "Michael" , lastName: "Johnson" , department: "Finance" , title: "Analyst" , phoneNumber: "555-987-6543" , startDate: today()-360 ),
a!map( id: 3, firstName: "Mary", lastName: "Reed" , department: "Engineering" , title: "Software Engineer" , phoneNumber: "555-456-0123" , startDate: today()-240 ),
},
a!formLayout(
label: "Example: Add,Update, or Remove Employee Data",
contents: {
a!gridLayout(
totalCount: count(local!employees),
headerCells: {
a!gridLayoutHeaderCell(label: "First Name" ),
a!gridLayoutHeaderCell(label: "Last Name" ),
a!gridLayoutHeaderCell(label: "Department" ),
a!gridLayoutHeaderCell(label: "Title" ),
a!gridLayoutHeaderCell(label: "Phone Number" ),
a!gridLayoutHeaderCell(label: "Start Date", align: "RIGHT" ),
/* For the "Remove" column */
a!gridLayoutHeaderCell(label: "" )
},
/* Only needed when some columns need to be narrow */
columnConfigs: {
a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:2 ),
a!gridLayoutColumnConfig(width: "ICON")
},
/*
* a!forEach() will take local!employee data and used that data to loop through an
* expression that creates each row.
*
* When modifying the recipe to work with your data, you only need to change:
* 1.) the number of fields in each row
* 2.) the types of fields for each column (i.e. a!textField() for text data elements)
* 3.) the fv!item elements. For example fv!item.firstName would change to fv!item.yourdata
*/
rows: a!forEach(
items: local!employees,
expression: a!gridRowLayout(
contents: {
/* For the First Name Column*/
a!textField(
/* Labels are not visible in grid cells but are necessary to meet accessibility requirements */
label: "first name " & fv!index,
value: fv!item.firstName,
saveInto: fv!item.firstName,
required: true
),
/* For the Last Name Column*/
a!textField(
label: "last name " & fv!index,
value: fv!item.lastName,
saveInto: fv!item.lastName,
required:true
),
/* For the Department Column*/
a!dropdownField(
label: "department " & fv!index,
placeholder: "-- Select -- ",
choiceLabels: { "Corporate", "Engineering", "Finance", "Human Resources", "Professional Services", "Sales" },
choiceValues: { "Corporate", "Engineering", "Finance", "Human Resources", "Professional Services", "Sales" },
value: fv!item.department,
saveInto: fv!item.department,
required:true
),
/* For the Title Column*/
a!textField(
label: "title " & fv!index,
value: fv!item.title,
saveInto: fv!item.title,
required:true
),
/* For the Phone Number Column*/
a!textField(
label: "phone number " & fv!index,
placeholder:"555-456-7890",
value: fv!item.phoneNumber,
saveInto: fv!item.phoneNumber
),
/* For the Start Date Column*/
a!dateField(
label: "start date " & fv!index,
value: fv!item.startDate,
saveInto: fv!item.startDate,
required:true,
align: "RIGHT"
),
/* For the Removal Column*/
a!richTextDisplayField(
value: a!richTextIcon(
icon: "close",
altText: "delete " & fv!index,
caption: "Remove " & fv!item.firstName & " " & fv!item.lastName,
link: a!dynamicLink(
value: fv!index,
saveInto: {
a!save(local!employees, remove(local!employees, save!value))
}
),
linkStyle: "STANDALONE",
color: "NEGATIVE"
)
)
},
id: fv!index
)
),
addRowlink: a!dynamicLink(
label: "Add Employee",
/*
* For your use case, set the value to a blank instance of your CDT using
* the type constructor, e.g. type!Employee(). Only specify the field
* if you want to give it a default value e.g. startDate: today()+1.
*/
value: {
startDate: today() + 1
},
saveInto: {
a!save(local!employees, append(local!employees, save!value))
}
),
rowHeader: 1
)
},
buttons: a!buttonLayout(
primaryButtons: a!buttonWidget(
label: "Submit",
submit: true
)
)
)
)
| Solve the following leet code problem |
Add, Remove, and Move Group Members Browser
Problem
Display the membership tree for a given group and provide users with the ability to add, remove, and move user members from a single interface.
|
Expression
Once you have created your groups and users, you will be ready to begin constructing the interface and process by following the steps below:
From the application, create a new interface called EX_addMoveRemoveUsers with the following inputs:
ri!initialGroup (Group) - the group whose direct members display in the first column of the browser, necessary to re-initialize the component after submittal.
ri!navigationPath (User or Group array) - the navigation path that the user was seeing when the form was submitted, necessary to re-initialize the component after submittal.
ri!usersToAdd (User Array) - the users to add as members to the ri!addedToGroup.
ri!addedToGroup (Group) - the chosen group to add users to.
ri!userToRemove (User) - the chosen user for the remove action.
ri!removeFromGroup (Group) - the group from which the ri!userToRemove is being removed.
ri!userToMove (User) - the chosen user for the move action.
ri!moveFromGroup (Group) - the chosen group to move the ri!userToMove from.
ri!moveToGroup (Group) - the chosen group to move the ri!userToMove to.
ri!btnAction (Text) - determines flow of the process. Can be "ADD", "REMOVE", or "MOVE".
Copy the following text into the expression view of EX_addMoveRemoveUsers :
a!localVariables(
local!selectionValue,
local!isUserSelected: runtimetypeof(local!selectionValue) = 'type! {http://www.appian.com/ae/types/2009}User',
local!actionTaken: if(
isnull(ri!btnAction),
false,
or(ri!btnAction = "ADD", ri!btnAction = "MOVE")
),
local!navigationLength: if(
isnull(ri!navigationPath),
0,
length(ri!navigationPath)
),
a!formLayout(
label: "Manage Group Membership",
contents: {
/*
If you use this as a related action, rather than using this picker
to choose the inital group, you would pass it in as context for
the action.
*/
a!pickerFieldGroups(
label: "Select a group to view its members",
maxSelections: 1,
value: ri!initialGroup,
saveInto: {
ri!initialGroup,
a!save(
{
ri!btnAction,
ri!userToRemove,
ri!userToMove,
ri!addedToGroup,
ri!removeFromGroup,
ri!navigationPath,
ri!moveFromGroup,
ri!moveToGroup,
ri!usersToAdd,
local!selectionValue
},
null
)
}
),
a!sectionLayout(
showWhen: not(isnull(ri!initialGroup)),
label: group(ri!initialGroup, "groupName") & " Group Members",
contents: {
a!buttonArrayLayout(
buttons: {
a!buttonWidget(
label: "Add Members",
disabled: or(
local!actionTaken,
local!navigationLength = 0
),
value: "ADD",
saveInto: {
ri!btnAction,
a!save(
ri!addedToGroup,
if(
/*
If the user has not navigated anywhere, or
the user has clicked on a user in the first column,
save the intial group
*/
or(
local!navigationLength = 0,
and(local!navigationLength = 1, local!isUserSelected)
),
ri!initialGroup,
if(
/* If a user is selected save the last group in the path */
local!isUserSelected,
togroup(ri!navigationPath[local!navigationLength - 1])
/* Otherwise save the end of the path */
togroup(ri!navigationPath[local!navigationLength])
)
)
)
}
),
a!buttonWidget(
label: "Remove Member",
value: "REMOVE",
saveInto: {
ri!btnAction,
a!save(ri!userToRemove, local!selectionValue),
/*
Since a user needs to be removed from a group, the button
needs to determine what group the user should be removed from.
*/
a!save(
ri!removeFromGroup,
if(
/* If the user is on the first column, save the initial group */
local!navigationLength = 1,
ri!initialGroup,
/* Otherwise save the group containing the selected user */
ri!navigationPath[local!navigationLength - 1]
)
),
/*
This navigation path will be used to pre-populate the group browser
when the user returns to this interface after the selected user has
been removed. Therefore, we must remove the selected user from the
navigation path to prevent an error.
*/
a!save(ri!navigationPath, rdrop(ri!navigationPath, 1))
},
disabled: or(local!actionTaken, not(local!isUserSelected)),
submit: true
),
a!buttonWidget(
label: "Move Member",
style: "OUTLINE",
disabled: or(local!actionTaken, not(local!isUserSelected)),
value: "MOVE",
saveInto: {
ri!btnAction,
a!save(ri!userToMove, local!selectionValue),
/*
Since a user needs to be removed from a group, the button
needs to determine what group the user should be removed from.
*/
a!save(
ri!moveFromGroup,
if(
/* If the user is in the first column save the initial group. */
local!navigationLength = 1,
ri!initialGroup,
/* Otherwise save the last group in the navigation path */
ri!navigationPath[local!navigationLength - 1]
)
),
a!save(ri!navigationPath, rdrop(ri!navigationPath, 1)),
a!save(ri!moveToGroup, ri!moveFromGroup)
}
)
}
),
/*
After selecting a member to move, the interface needs to allow the
user to select a group to move the member to. To limit what can
be selected to a group and not a user, we switch the component
to a group browser
*/
a!groupBrowserFieldColumns(
labelPosition: "COLLAPSED",
showWhen: ri!btnAction = "MOVE",
rootGroup: ri!initialGroup,
pathValue: ri!navigationPath,
pathSaveInto: ri!navigationPath,
selectionValue: ri!moveToGroup,
selectionSaveInto: ri!moveToGroup
),
/*
Unless the user is in the process of moving members,
the user has the option to select a user to move or remove
or a group to add members to.
*/
a!userAndGroupBrowserFieldColumns(
labelPosition: "COLLAPSED",
showWhen: not(ri!btnAction = "MOVE"),
rootGroup: ri!initialGroup,
pathValue: ri!navigationPath,
pathSaveInto: ri!navigationPath,
selectionValue: local!selectionValue,
selectionSaveInto: local!selectionValue,
readOnly: or(
ri!btnAction = "ADD",
ri!btnAction = "REMOVE"
)
),
/*
Navigation cannot be cleared without configuration, so
this link lets the user add members to the initial group.
*/
a!linkField(
labelPosition: "COLLAPSED",
showWhen: not( local!actionTaken),
links: {
a!dynamicLink(
label: "+ Add Users to " & group(ri!initialGroup, "groupName"),
value: "ADD",
saveInto: {
ri!btnAction,
a!save(ri!addedToGroup, ri!initialGroup)
}
)
}
)
}
),
a!sectionLayout(
label: "Add Users to " & group(ri!addedToGroup, "groupName"),
showWhen: ri!btnAction = "ADD",
contents: {
a!pickerFieldUsers(
label: "Users to Add",
value: ri!usersToAdd,
saveInto: a!save(ri!usersToAdd, getdistinctusers(save!value)),
required: true
)
}
),
a!sectionLayout(
label: "Move User",
showWhen: ri!btnAction = "MOVE",
contents: {
a!richTextDisplayField(
labelPosition: "COLLAPSED",
value: {
"Move ",
a!richTextItem(
text: user(ri!userToMove, "firstName") & " " & user(ri!userToMove, "lastName"),
style: "STRONG"
),
" from ",
a!richTextItem(
text: group(ri!moveFromGroup, "groupName"),
style: "STRONG"
),
" to"
},
readOnly: true
),
a!pickerFieldGroups(
labelPosition: "COLLAPSED",
groupFilter: ri!initialGroup,
value: ri!moveToGroup,
saveInto: ri!moveToGroup,
required: true
)
}
),
a!buttonLayout(
showWhen: local!actionTaken,
primaryButtons: {
a!buttonWidget(
label: if(ri!btnAction = "ADD", "Add Users", "Move User"),
style: "SOLID",
disabled: if(
ri!btnAction = "MOVE",
or(ri!moveFromGroup = ri!moveToGroup, isnull(ri!moveToGroup)),
if(isnull(ri!usersToAdd), true, length(ri!usersToAdd) = 0)
),
submit: true
)
},
secondaryButtons: {
/*
Allows the user to cancel the selected action. If the user
cancels out of the action, we need to clear all the
selection variables
*/
a!buttonWidget(
label: "Cancel",
style: "OUTLINE",
showWhen: local!actionTaken,
value: null,
saveInto: {
ri!btnAction,
ri!userToMove,
ri!userToRemove,
ri!addedToGroup,
ri!removeFromGroup,
ri!moveFromGroup,
ri!moveToGroup,
ri!usersToAdd,
local!selectionValue
}
)
}
)
},
buttons: a!buttonLayout(
primaryButtons: {
a!buttonWidget(
label: "Close",
value: "CLOSE",
saveInto: ri!btnAction,
submit: true,
validate: false
)
}
)
)
)
Notable expression detailsCopy link to clipboard
The comments in the expression above point out many difficult concepts in this recipe. Some of the most important to note are listed below:
When managing group membership in process, keep track of the navigation path. This allows you to reinitialize the browser where the user left off, creating the feeling that the user never leaves the form. At the same time, you must be sure that the navigation path does not become invalidated due to altered group membership. In the example above, if a user is removed from a groups membership, it is also removed from the navigation path.
To extract the parent of the selected value from the path, use the following expression :
if(
length(ri!navigationPath) = 1,
ri!initialGroup,
togroup(ri!navigationPath[length(ri!navigationPath) - 1])
)
If using a user & group browser, use the runtimetypeof() combined with 'type!User' and 'type!Group' to determine what type of value is selected.
If using the recipe for a related action, pass the initial group in the related action context and remove the group picker from the interface
Getting the interface into a process model :
To be able move group members, we need to use a process. We will continue this recipe by:
Create a new process model named Manage Group Members.
Add a new user input task, labeled Manage Group Members, connecting it to the start node. Make the connection an activity chain.
Set this as a user input task rather than a start form so that you can loop back to it.
On the Forms tab, enter the name of your EX_addMoveRemoveUsers interface in the search box and select it.
Click Yes when the Process Modeler asks, "Do you want to import the rule inputs?". This will create node inputs.
On the Data Tab, for each activity class variable, add a duplicate process variable to save the activity class variable.
For initialGroup, set the corresponding process variable as the input value.
For navigationPath, set the corresponding process variable as the input value.
Assign the task to the process initiator.
To create a decision:
Create a new XOR node below the input task and name it Do What? Connect the two with an activity chain.
Move the end node to the left of the XOR, and connect the two.
Now you can start to actually build the nodes that handle the actions.
To build the nodes connected to the gateway:
Create three new sets of nodes, stemming from the gateway. Activity chain all connections going forward.
Add Add Group Members and do not change the name.
Add Remove Group Members and change the name to Remove Group Member.
Add Add Group Members and Remove Group Members and connect them.
Change the names to Add Group Member for Move and Remove Group Member for Move, respectively.
Connect Add Group Members, Remove Group Member, and Remove Group Member for Move back to Manage Group Membership, and activity chain the connections.
At this point, your process should look something like this:
Configure the Do What? logic:
If pv!btnAction = "ADD" is True, then go to Add Group Member.
Else If pv!btnAction = "REMOVE" is True, then go to Remove Group Member.
Else If pv!btnAction = "MOVE" is True, then go to Add Group Member for Move.
Else if none are true, go to End Node.
To configure the remaining nodes in the process model and publish as an action:
In Add Group Member:
Set Choose New Members to pv!usersToAdd.
Set Choose Group to pv!addToGroup.
In Remove Group Member:
Set Choose Members to pv!userToRemove.
Set Group to pv!removeFromGroup.
In Move to Group:
Set Choose New Members to pv!userToMove.
Set Choose Group to pv!moveToGroup.
In Move from Group:
Set Choose Members to pv!userToMove.
Set Group to pv!moveFromGroup.
Save & Publish the process model.
From the application, click Settings, then Application Actions.
Add the process model Manage Group Members as an action called Manage Group Members.
Publish your application.
Test it outCopy link to clipboard
At this point, you are ready to manage your groups membership.
To try it out:
Go to the actions tab, click on your new Manage Group Members action.
Click on a group and click Add Members.
In the picker, type in names of users, and click Add Users to submit the form. You should be brought back to the interface, and the users should now appear as members of the group.
Click on one of the new users.
Click Remove Member. The user should no longer be a member of the group.
Click on another user
Click Move Member.
Click on another group or type a group name in the picker. Click Move User to confirm. The user should now be moved.
| Solve the following leet code problem |
Aggregate data and conditionally display it in a pie chart or grid.
In this pattern, we will calculate the total number of employees in each department and display it in a pie chart and a read-only grid. Then, we'll use a link field to conditionally display each component.
This design pattern is not recommended for offline interfaces because reflecting immediate changes in an interface based on user interaction requires a connection to the server.
This scenario demonstrates:
How to use a link to switch between two different interface components.
How to aggregate on two dimensions
| a!localVariables(
/* This variable is set to true initially and is referenced in the showWhen parameters for
the pie chart and inversely in the grid. The dynamic link at the end reverses this value
on click. */
local!displayAsChart: true,
/* Since we want to pass the data to the pie chart and the grid, we query for the data in
a local variable. Otherwise, we would just query directly from the data parameter of
the gridField(). */
local!datasubset: a!queryRecordType(
recordType: recordType!Employee,
fields: a!aggregationFields(
groupings: a!grouping(
field: recordType!Employee.fields.department,
alias: "department"
),
measures: a!measure(
field: recordType!Employee.fields.id,
function: "COUNT",
alias: "id_count"
)
),
pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 5000)
),
{
a!pieChartField(
series: {
a!forEach(
items: local!datasubset.data,
expression: a!chartSeries(
label: fv!item.department,
data: fv!item.id_count
)
)
},
colorScheme: "BERRY",
style: "DONUT",
seriesLabelStyle: "LEGEND",
/* Since the initial value is true, the pie chart displays on load. We could change
the initial value of local!displayAsChart to swap that behavior without having to
otherwise change the logic of this interface. */
showWhen: local!displayAsChart
),
a!gridField(
data: local!datasubset.data,
columns: {
a!gridColumn(
label: "Department",
sortField: "department",
value: fv!row.department
),
a!gridColumn(
label: "Total",
sortField: "id_count",
value: fv!row.id_count
)
},
/* Here the grid only shows when local!displayAsChart is not true. */
showWhen: not(local!displayAsChart),
rowHeader: 1
),
a!linkField(
labelPosition: "COLLAPSED",
links: a!dynamicLink(
label: "Show as " & if(local!displayAsChart, "Grid", "Chart"),
/* The not() function simply converts a true to false, or false to true, which
simplifies the toggle behavior. */
value: not(local!displayAsChart),
saveInto: local!displayAsChart
),
align: "CENTER"
)
}
)
| Solve the following leet code problem |
Aggregate Data and Display in a Chart
This expression uses direct references to the Employee record type, created in the Records Tutorial. If you've completed that tutorial in your environment, you can change the existing record-type references in this pattern to point to your Employee record type instead.
https://docs.appian.com/suite/help/24.1/Records_Tutorial.html
This scenario demonstrates:
How to aggregate data and display in a pie chart
|
Create this pattern
You can easily create this pattern in design mode when you use a record type as the source of your chart.
To create this pattern in design mode:
Open a new or empty interface object.
From the PALETTE, drag a Pie Chart component into the interface.
From Data Source, select RECORD TYPE and search for the Employee record type.
Under Primary Grouping, select the department field.
Under Measure, use the dropdown to select Count of, then select the id field.
Under Style, use the dropdown to select Pie.
{
a!pieChartField(
data: recordType!Employee,
config: a!pieChartConfig(
primaryGrouping: a!grouping(
field: recordType!Employee.fields.department,
alias: "department_primaryGrouping"
),
measures: {
a!measure(
function: "COUNT",
field: recordType!Employee.fields.id,
alias: "id_count_measure1"
)
},
dataLimit: 100
),
label: "Pie Chart",
labelPosition: "ABOVE",
colorScheme: "CLASSIC",
style: "PIE",
seriesLabelStyle: "ON_CHART",
height: "MEDIUM",
refreshAfter: "RECORD_ACTION"
)
}
| Solve the following leet code problem |
Aggregate data by multiple fields and display it in a stacked column chart. In this pattern, we will calculate the total number of employees for each title in each department and display it in a stacked column chart.
How to aggregate data by multiple fields and display in a column chart
| a)
To create this pattern in design mode:
https://docs.appian.com/suite/help/24.1/Chart_Configuration_Using_Records.html
Open a new or empty interface object.
From the PALETTE, drag a Column Chart component into the interface.
From Data Source, select RECORD TYPE and search for the Employee record type.
Under Primary Grouping, select the department field.
Click ADD GROUPING.
Under Secondary Grouping, select the title field.
Under Measure, use the dropdown to select Count of, then select the id field.
From Stacking, select Normal.
For the X-Axis Title, enter Department.
For the Y-Axis Title, enter Number of Employees.
b)
a!columnChartField(
data: recordType!Employee,
config: a!columnChartConfig(
primaryGrouping: a!grouping(
field: recordType!Employee.fields.department,
alias: "department_primaryGrouping"
),
secondaryGrouping: a!grouping(
field: recordType!Employee.fields.title,
alias: "title_secondaryGrouping"
),
measures: {
a!measure(
function: "COUNT",
field: recordType!Employee.fields.id,
alias: "id_count_measure1"
)
},
dataLimit: 100
),
label: "Column Chart",
xAxisTitle: "Department",
yAxisTitle: "Number of Employees",
stacking: "NORMAL",
showLegend: true,
showTooltips: true,
labelPosition: "ABOVE",
colorScheme: "CLASSIC",
height: "MEDIUM",
xAxisStyle: "STANDARD",
yAxisStyle: "STANDARD"
)
| Solve the following leet code problem |
Aggregate Data on a Date or Date and Time Field
Aggregate data, specifically the total number of employees by date.
|
a)
To create this pattern in design mode:
Open a new or empty interface object.
From the PALETTE, drag a Bar Chart component into the interface.
From Data Source, select RECORD TYPE and search for the Employee record type.
Under Primary Grouping, select the startDate field.
Click the edit icon next to the selected field and set Time Interval to Month of Year.
Under Format Value, use the dropdown to choose a pre-defined format. Select the short text date.
Click Bar Chart to return to the bar chart configuration.
Click ADD GROUPING.
Under Secondary Grouping, select the department field.
Under Measure, use the dropdown to select Count of, then select the id field.
From Stacking, select Normal.
From Color Scheme, select Ocean.
b)
a!barChartField(
data: recordType!Employee,
config: a!barChartConfig(
primaryGrouping: a!grouping(
field: recordType!Employee.fields.startDate,
alias: "startDate_month_of_year_primaryGrouping",
interval: "MONTH_OF_YEAR_SHORT_TEXT"
),
secondaryGrouping: a!grouping(
field: recordType!Employee.fields.department,
alias: "department_secondaryGrouping"
),
measures: {
a!measure(
function: "COUNT",
field: recordType!Employee.fields.id,
alias: "id_count_measure1"
)
},
dataLimit: 100
),
label: "Bar Chart",
labelPosition: "ABOVE",
stacking: "NORMAL",
showLegend: true,
showTooltips: true,
colorScheme: "OCEAN",
height: "MEDIUM",
xAxisStyle: "STANDARD",
yAxisStyle: "STANDARD"
)
| Solve the following leet code problem |
Aggregate Data using a Filter and Display in a Chart
Aggregate data, specifically the total number of employees for each title in the Engineering department, to display in a bar chart.
This scenario demonstrates:
How to aggregated data and display it in a bar chart
How to filter the bar chart
| a)
To create this pattern in design mode:
Open a new or empty interface object.
From the PALETTE, drag a Bar Chart component into the interface.
From Data Source, select RECORD TYPE and search for the Employee record type.
Under Primary Grouping, select the title field.
Under Measure, use the dropdown to select Count of, then select the id field.
Click the edit icon next to the measure.
Under Label, enter Total.
Return to the Bar Chart configuration and click FILTER RECORDS.
Under Field, use the dropdown to select the department field.
Under Condition, use the dropdown to select equal to.
Under Value, enter Engineering.
Click OK.
b)
{
a!barChartField(
data: a!recordData(
recordType: recordType!Employee,
filters: a!queryLogicalExpression(
operator: "AND",
filters: {
a!queryFilter(
field: recordType!Employee.fields.department,
operator: "=",
value: "Engineering"
)
},
ignoreFiltersWithEmptyValues: true
)
),
config: a!barChartConfig(
primaryGrouping: a!grouping(
field: recordType!Employee.fields.title,
alias: "title_primaryGrouping"
),
measures: {
a!measure(
label: "Total",
function: "COUNT",
field: recordType!Employee.fields.id,
alias: "id_count_measure1"
)
},
dataLimit: 100
),
label: "Bar Chart",
labelPosition: "ABOVE",
stacking: "NONE",
showLegend: true,
showTooltips: true,
colorScheme: "OCEAN",
height: "MEDIUM",
xAxisStyle: "STANDARD",
yAxisStyle: "STANDARD",
refreshAfter: "RECORD_ACTION"
)
}
Notable implementation details:
The expression for the filter is being passed into the filters parameter of a!recordData(). Learn more about this function.
In the final expression, the chart color scheme "OCEAN" has been added. You can change the color scheme or create your own custom color scheme.
| Solve the following leet code problem |
Display a hierarchical data browser.
This design pattern is not recommended for offline interfaces because reflecting immediate changes in an interface based on user interaction requires a connection to the server.
This columns browser shows regions, account executives located in each region, and the customers associated with each account executive. Regions, account executives, and customers each have a different display configuration.
This scenario demonstrates:
How to display data in a columns browser
How to dynamically retrieve data for each column depending on the level of the hierarchy
How to dynamically configure the display of each node depending on the type of data displayed in the hierarchy
|
Setup
For this recipe, you'll need a hierarchical data set. Create the following three custom data types with corresponding fields.
EXAMPLE_Region
id (Number (Integer))
name (Text)
EXAMPLE_AccountExec
id (Number (Integer))
firstName (Text)
lastName (Text)
regionId (Number (Integer))
EXAMPLE_Customer
id (Number (Integer))
name (Text)
accountExecId (Number (Integer))
These data types have a hierarchical relationship. Note how EXAMPLE_AccountExec has a field for region and EXAMPLE_Customer has a field for account executive.
Sail code :
a!localVariables(
/*
This is sample data for the recipe. In your columns browser component,
you'll use data from other sources, like records or entities.
*/
local!regions:{
'type!{urn:com:appian:types}EXAMPLE_Region'( id: 1, name: "North America" ),
'type!{urn:com:appian:types}EXAMPLE_Region'( id: 2, name: "South America" ),
'type!{urn:com:appian:types}EXAMPLE_Region'( id: 3, name: "EMEA" ),
'type!{urn:com:appian:types}EXAMPLE_Region'( id: 4, name: "APAC" )
},
local!accountExecs:{
'type!{urn:com:appian:types}EXAMPLE_AccountExec'( id: 1, firstName: "Susan", lastName: "Taylor", regionId: 1 ),
'type!{urn:com:appian:types}EXAMPLE_AccountExec'( id: 2, firstName: "Sharon", lastName: "Hill", regionId: 3 ),
'type!{urn:com:appian:types}EXAMPLE_AccountExec'( id: 3, firstName: "Kevin", lastName: "Singh", regionId: 2 ),
'type!{urn:com:appian:types}EXAMPLE_AccountExec'( id: 4, firstName: "Daniel", lastName: "Lewis", regionId: 3 )
},
local!customers:{
'type!{urn:com:appian:types}EXAMPLE_Customer'( id: 1, name: "Lebedev", accountExecId: 2 ),
'type!{urn:com:appian:types}EXAMPLE_Customer'( id: 2, name: "Parsec Express", accountExecId: 3 ),
'type!{urn:com:appian:types}EXAMPLE_Customer'( id: 3, name: "Dengar Dynamics", accountExecId: 2 ),
'type!{urn:com:appian:types}EXAMPLE_Customer'( id: 4, name: "Almach", accountExecId: 1 )
},
local!path,
local!selection,
a!sectionLayout(
contents:{
a!hierarchyBrowserFieldColumns(
label: "Interface Recipe: Columns Browser",
/*
This data comes from a local variable for the recipe. Substitute your
rule here when you make your own columns browser component.
*/
firstColumnValues: local!regions,
/*
This is where you specify how a node appears in the browser given
its type. If the node is a region, show the name field. If the node
is an account executive, show the first name and last name fields.
*/
nodeConfigs: if(
typeof(fv!nodeValue) = 'type!{urn:com:appian:types}EXAMPLE_Region',
a!hierarchyBrowserFieldColumnsNode(
id: fv!nodeValue.id,
label: fv!nodeValue.name,
image: a!documentImage(document: a!iconIndicator("HARVEY_0"))
),
if(
typeof(fv!nodeValue) = 'type!{urn:com:appian:types}EXAMPLE_AccountExec',
a!hierarchyBrowserFieldColumnsNode(
id: fv!nodeValue.id,
label: fv!nodeValue.firstName & " " & fv!nodeValue.lastName,
image: a!documentImage(document: a!iconIndicator("HARVEY_50"))
),
if(
typeof(fv!nodeValue)='type!{urn:com:appian:types}EXAMPLE_Customer',
a!hierarchyBrowserFieldColumnsNode(
id: fv!nodeValue.id,
label: fv!nodeValue.name,
image: a!documentImage(document: a!iconIndicator("HARVEY_100")),
isDrillable: false
),
{}
)
)
),
pathValue: local!path,
pathSaveInto: local!path,
nextColumnValues: if(
/*
Check to see if the node is a region. If so, look up account
executives for that region. Substitute your type and rule here.
*/
typeof(fv!nodeValue)='type!{urn:com:appian:types}EXAMPLE_Region',
index(local!accountExecs, wherecontains(fv!nodeValue.id, local!accountExecs.regionId), {}),
if(
/*
Check to see if the node is an account executive. If so, look up customers
for that account executive. Substitute your type and rule here.
*/
typeof(fv!nodeValue)='type!{urn:com:appian:types}EXAMPLE_AccountExec',
index(local!customers, wherecontains(fv!nodeValue.id, local!customers.accountExecId), {}),
{}
)
),
selectionValue: local!selection,
selectionSaveInto: local!selection,
height: "SHORT"
),
a!textField(
label: "path",
instructions: typename(typeof(local!path)),
value: local!path,
readOnly: true
),
a!textField(
label: "selection",
instructions: typename(typeof(local!selection)),
value: local!selection,
readOnly: true
)
}
)
)
The data provided here is loaded into local variables. Refer to the comments in the example interface to substitute your own data and queries. For heterogenous data sets like this example, remember to specify how each type should retrieve its next column values and how each type should be displayed.
The images shown in this example are simple icons configured with a!iconIndicator. You can use this function or provide different document or web images. Choose icons that makes sense for your data to create a compelling visual experience in your interfaces.
nodeConfigs is configured using a!hierarchyBrowserFieldColumnsNode(). This determines how items in the hierarchy are displayed. In this snippet, it determines how regions are displayed.
nextColumnValues determines what appears in the next column based on the type of the current node, fv!nodeValue.
The customer nodes are configured not to be drillable because we know that this column is the end of the hierarchy.
| Solve the following leet code problem |
Build a Wizard with Milestone Navigation
Use the milestone component to show steps in a wizard.
Configure links for each step in the milestone so that the user can move forward or return to any step.
This scenario demonstrates:
How to create a wizard using the showWhen parameter of an interface component
How to use a milestone field to show the current step of the wizard
How to show and change the style of buttons
| a!localVariables(
local!employee:a!map( firstName:null, lastName:null, department:null, title:null, phoneNumber:null, startDate:null ),
local!currentStep: 1,
local!steps: {"Step 1", "Step 2", "Review"},
a!formLayout(
label: "Example: Onboarding Wizard",
contents:{
a!sectionLayout(
contents:{
a!milestoneField(
steps: local!steps,
active: local!currentStep
)
}
),
a!sectionLayout(
contents:{
a!columnsLayout(
columns:{
a!columnLayout(
contents:{
a!textField(
label: "First Name",
labelPosition: if( local!currentStep = 3, "ADJACENT","ABOVE"),
value: local!employee.firstName,
saveInto: local!employee.firstName,
readOnly: local!currentStep = 3,
required: not(local!currentStep = 3),
showWhen: or( local!currentStep = {1,3} )
),
a!textField(
label: "Last Name",
labelPosition: if( local!currentStep = 3, "ADJACENT","ABOVE"),
value: local!employee.lastName,
saveInto: local!employee.lastName,
readOnly: local!currentStep = 3,
required: not(local!currentStep = 3),
showWhen: or( local!currentStep = {1,3} )
),
a!textField(
label: "Phone Number",
labelPosition: if( local!currentStep = 3, "ADJACENT","ABOVE"),
value: local!employee.phoneNumber,
saveInto: local!employee.phoneNumber,
readOnly: local!currentStep = 3,
required: not(local!currentStep = 3),
showWhen: or( local!currentStep = {2,3} )
)
}
),
a!columnLayout(
contents:{
a!textField(
label: "Department",
labelPosition: if( local!currentStep = 3, "ADJACENT","ABOVE"),
value: local!employee.department,
saveInto: local!employee.department,
readOnly: local!currentStep = 3,
required: not(local!currentStep = 3),
showWhen: or( local!currentStep = {1,3} )
),
a!textField(
label: "Title",
labelPosition: if( local!currentStep = 3, "ADJACENT","ABOVE"),
value: local!employee.title,
saveInto: local!employee.title,
readOnly: local!currentStep = 3,
required: not(local!currentStep = 3),
showWhen: or( local!currentStep = {1,3} )
),
a!dateField(
label: "Start Date",
labelPosition: if( local!currentStep = 3, "ADJACENT","ABOVE"),
value: local!employee.startDate,
saveInto: local!employee.startDate,
readOnly: local!currentStep = 3,
required: not(local!currentStep = 3),
showWhen: or( local!currentStep = {2,3} )
)
}
)
}
)
}
)
},
buttons: a!buttonLayout(
primaryButtons: {
a!buttonWidget(
label: "Go Back",
value: local!currentStep - 1,
saveInto: local!currentStep,
showWhen: or( local!currentStep = {2,3} )
),
a!buttonWidget(
label: if( local!currentStep = 1, "Next", "Go to Review"),
value: local!currentStep + 1,
saveInto: local!currentStep,
validate: true,
showWhen: or( local!currentStep = {1,2} )
),
a!buttonWidget(
label: "Onboard Employee",
style: "SOLID",
submit: true,
showWhen: local!currentStep = 3
)
}
)
)
)
Notable Implementation Details
The showWhen parameter is used extensively to conditionally show particular fields as well as set requiredness & read only setting.
Each "Next" button is configured to increment local!currentStep. Validate is set to true, which ensures all fields are required before continuing on to the next step.
Each "Go Back" button is not configured to enforce validation. This allows the user to go to a previous step even if the current step has null required fields and other invalid fields. This button also decrements local!currentStep by one.
The milestone field is configured without links, however links could be added that navigate a user back to a particular step.
| Solve the following leet code problem |
Build an Interface Wizard
Divide a big form into sections presented one step at a time with validation.
Wizards should be used to break up a large form into smaller steps rather than activity-chaining. Users can step back and forth within a wizard without losing data in between steps.
All the fields must be valid before the user is allowed to move to the next steps. However, the user is allowed to move to a previous step even if the fields in the current step aren't valid. The last step in the wizard is a confirmation screen.
This scenario demonstrates:
How to create a wizard using the showWhen parameter of an interface component
How to conditionally set readOnly and required on an interface component
How to show and change the style of buttons
| SAIL code:
a!localVariables(
local!employee:a!map( firstName:null, lastName:null, department:null, title:null, phoneNumber:null, startDate:null ),
local!currentStep: 1,
a!formLayout(
label: "Example: Onboarding Wizard",
contents:{
a!columnsLayout(
columns:{
a!columnLayout(
contents:{
a!textField(
label: "First Name",
labelPosition: if( local!currentStep = 3, "ADJACENT","ABOVE"),
value: local!employee.firstName,
saveInto: local!employee.firstName,
readOnly: local!currentStep = 3,
required: not( local!currentStep = 3),
showWhen: or( local!currentStep = {1,3} )
),
a!textField(
label: "Last Name",
labelPosition: if( local!currentStep = 3, "ADJACENT","ABOVE"),
value: local!employee.lastName,
saveInto: local!employee.lastName,
readOnly: local!currentStep = 3,
required: not( local!currentStep = 3),
showWhen: or( local!currentStep = {1,3} )
),
a!textField(
label: "Phone Number",
labelPosition: if( local!currentStep = 3, "ADJACENT","ABOVE"),
value: local!employee.phoneNumber,
saveInto: local!employee.phoneNumber,
readOnly: local!currentStep = 3,
required: not( local!currentStep = 3),
showWhen: or( local!currentStep = {2,3} )
)
}
),
a!columnLayout(
contents:{
a!textField(
label: "Department",
labelPosition: if( local!currentStep = 3, "ADJACENT","ABOVE"),
value: local!employee.department,
saveInto: local!employee.department,
readOnly: local!currentStep = 3,
required: not( local!currentStep = 3),
showWhen: or( local!currentStep = {1,3} )
),
a!textField(
label: "Title",
labelPosition: if( local!currentStep = 3, "ADJACENT","ABOVE"),
value: local!employee.title,
saveInto: local!employee.title,
readOnly: local!currentStep = 3,
required: not( local!currentStep = 3),
showWhen: or( local!currentStep = {1,3} )
),
a!dateField(
label: "Start Date",
labelPosition: if( local!currentStep = 3, "ADJACENT","ABOVE"),
value: local!employee.startDate,
saveInto: local!employee.startDate,
readOnly: local!currentStep = 3,
required: not( local!currentStep = 3),
showWhen: or( local!currentStep = {2,3} )
)
}
)
}
)
},
buttons: a!buttonLayout(
primaryButtons: {
a!buttonWidget(
label: "Go Back",
value: local!currentStep - 1,
saveInto: local!currentStep,
showWhen: or( local!currentStep = {2,3} )
),
a!buttonWidget(
label: if( local!currentStep = 1, "Next", "Go to Review"),
value: local!currentStep + 1,
saveInto: local!currentStep,
validate: true,
showWhen: or( local!currentStep = {1,2} )
),
a!buttonWidget(
label: "Onboard Employee",
style: "SOLID",
submit: true,
showWhen: local!currentStep = 3
)
}
)
)
)
Notable implementation details
The showWhen parameter is used extensively to conditionally show particular fields as well as set requiredness & read only setting.
Each "Next" button is configured to increment local!currentStep. Validate is set to true, which ensures all fields are required before continuing on to the next step.
Each "Go Back" button is not configured to enforce validation. This allows the user to go to a previous step even if the current step has null required fields and other invalid fields. This button also decrements local!currentStep by one.
| Solve the following leet code problem |
Conditionally hide a column in a read-only grid when all data for that column is a specific value.
Use Case
You can configure a read-only grid to conditionally hide a grid column, show a grid column, or both when the user selects a filter. This interface expression pattern demonstrates how to use a!gridField() to configure a read-only grid that conditionally hides the Department column and makes the Phone Number column visible when the user selects a Department filter. It also shows you how to use a record type as the grid's data source and bring in additional features configured in the record type.
Use the pattern in this example as a template when you want to:
Conditionally hide or show certain record data based on a user's interaction with the grid.
Configure a user filter for a specific grid only.
|
The expression pattern below shows you how to:
Conditionally hide a column in a read-only grid based on the user's interaction.
Use a!queryFilter() to query the record type to return a datasubset that matches the filter value selected.
Use record type field references, recordType!<record type name>.fields.<field name>, to reference record fields in the grid and fv!row with bracket notation to call the field values in a grid.
Use a!localVariables to store the filter value a user selects.
Use a!dropdownField() to configure a filter dropdown for the grid.
SAIL code:
a!localVariables(
/* In your application, replace the values defined by local!departments
* with a constant that stores the filter values you want to use in your
* grid. Then use cons!<constant name> to reference the constant in
* local!departments. */
local!departments: { "Corporate", "Engineering", "Finance", "HR", "Professional Services", "Sales" },
/* Use a local variable to hold the name of the department filter the
* user selects in the filter dropdown. This example, uses
* local!selectedDepartment */
local!selectedDepartment,
{
a!sectionLayout(
label: "",
contents: {
a!richTextDisplayField(
value: {
a!richTextItem(
/* The department name is appended to Employees and displayed
* only when the user selects a department filter in the
* dropdown list. */
text: {"Employees"&if(isnull(local!selectedDepartment),null," in "&upper(local!selectedDepartment))},
size: "MEDIUM",
style: {
"STRONG"
}
)
}
),
a!columnsLayout(
columns: {
a!columnLayout(
contents: {
/* We used the dropdownField() component to create an
* adhoc user filter for the grid. It pulls in the
* department names stored in local!departments as
* choiceLabels and choiceValues and saves the filter
* value selected by the user in local!selectedDepartment. */
a!dropdownField(
label: "Department ",
placeholder: "-- Filter By Department -- ",
choiceLabels: local!departments,
choiceValues: local!departments,
value: local!selectedDepartment,
saveInto: local!selectedDepartment
)
},
width: "NARROW_PLUS"
)
}
),
a!gridField(
data: a!recordData(
recordType: recordType!Employee,
filters: a!queryLogicalExpression(
operator: "AND",
filters: {
a!queryFilter(
field: recordType!Employee.fields.department,
operator: "=",
value: local!selectedDepartment
)
},
ignoreFiltersWithEmptyValues: true
)
),
columns: {
a!gridColumn(
label: "First Name",
sortField:recordType!Employee.fields.firstName,
value: fv!row[recordType!Employee.fields.firstName]
),
a!gridColumn(
label: "Last Name",
sortField: recordType!mployee.fields.lastName,
value: fv!row[recordType!Employee.fields.lastName]
),
a!gridColumn(
label: "Department",
sortField: recordType!Employee.fields.department,
value: fv!row[recordType!Employee.fields.department],
/* The Department column is shown only when the user has not
* selected a department filter in the dropdown list. */
showWhen: isnull(local!selectedDepartment)
),
a!gridColumn(
label: "Title",
sortField: recordType!Employee.fields.title,
value: fv!row[recordType!Employee.fields.title]
),
/* The Phone Number column is shown when the user selects
* a Department filter. */
a!gridColumn(
label: "Phone Number",
sortField: recordType!Employee.fields.phoneNumber,
value: fv!row[recordType!Employee.fields.phoneNumber],
showwhen: not(isnull(local!selectedDepartment))
)
}
)
}
)
}
)
| Solve the following leet code problem |
Configure Buttons with Conditional Requiredness
Present two buttons to the end user and only make certain fields required if the user clicks a particular button
This scenario demonstrates:
How to use validation groups to evaluate particular fields on a form
How to use the requiredMessage parameter to set custom required messages
| a!localVariables(
/*
* All of these local variables could be combined into the employee CDT and passed into
* a process model via a rule input
*/
local!firstName,
local!lastName,
local!department,
local!title,
local!phoneNumber,
local!startDate,
/*
* local!isFutureHire is a placeholder variable used to set the validation group trigger.
* When isFutureHire is set to true, a user can skip phone number and start date.
*/
local!isFutureHire,
a!formLayout(
label: "Example: Add Employee with Conditional Requiredness",
contents: {
a!textField(
label: "First Name",
value: local!firstName,
saveInto: local!firstName,
required: true
),
a!textField(
label: "Last Name",
value: local!lastName,
saveInto: local!lastName,
required: true
),
a!dropdownField(
label: "Department",
placeholder: "-- Select a Department -- ",
choiceLabels: { "Corporate", "Engineering", "Finance", "Human Resources", "Professional Services", "Sales" },
choiceValues: { "Corporate", "Engineering", "Finance", "Human Resources", "Professional Services", "Sales" },
value: local!department,
saveInto: local!department,
required: true
),
a!textField(
label: "Title",
value: local!title,
saveInto: local!title,
required: true
),
/*
* When a field has a validation group set, the required parameter and any validations
* are deferred until the validation group is triggered by a button or link.
*/
a!textField(
label: "Phone Number",
placeholder: "555-456-7890",
value: local!phoneNumber,
saveInto: local!phoneNumber,
required:true,
requiredMessage:"A phone number is needed if you're going to onboard this employee",
validationGroup:"Future_Hire"
),
a!dateField(
label: "Start Date",
value: local!startDate,
saveInto: local!startDate,
required:true,
requiredMessage:"A start date is needed if you're going to onboard this employee",
validationGroup:"Future_Hire"
)
},
buttons: a!buttonLayout(
primaryButtons: {
a!buttonWidget(
label: "Submit Future Onboarding",
style: "OUTLINE",
color: "SECONDARY",
value: true,
saveInto: local!isFutureHire,
submit: true
),
a!buttonWidget(
label: "Onboard Employee Now",
value: false,
saveInto: local!isFutureHire,
submit: true,
validationGroup: "Future_Hire"
)
}
)
)
)
| Solve the following leet code problem |
Configure Cascading Dropdowns
Show different dropdown options depending on the user selection.
This scenario demonstrates:
How to setup a dropdown field's choice labels and values based of another dropdown's selection.
How to clear a child dropdown selection when the parent dropdown value changes.
| a!localVariables(
local!selectedDepartment,
local!selectedTitle,
/*
* Hardcoded values are stored here through the choose function. Typically
* this data would live with the department in a lookup value. In that case
* local!selectedDepartment would act as a filter on that query to bring
* back titles by department.
*/
local!availableTitles:choose(
if(isnull(local!selectedDepartment), 1, local!selectedDepartment),
{"CEO","CFO","COO","Executive Assistant"},
{"Director","Quality Engineer","Manager","Software Engineer"},
{"Accountant","Manager","Director"},
{"Coordinator","Director","Manager"},
{"Consultant","Principal Consultant","Senior Consultant"},
{"Account Executive","Director","Manager"}
),
a!sectionLayout(
label: "Example: Cascading Dropdowns",
contents: {
a!dropdownField(
label: "Department",
choiceLabels: { "Corporate", "Engineering", "Finance", "Human Resources", "Professional Services", "Sales" },
choiceValues: { 1, 2, 3, 4, 5, 6 },
placeholder: "-- Select a Department -- ",
value: local!selectedDepartment,
saveInto: {
local!selectedDepartment,
a!save(local!selectedTitle, null)
}
),
a!dropdownField(
label: "Title",
choiceLabels: local!availableTitles,
choiceValues: local!availableTitles,
placeholder: "--- Select a Title ---",
value: local!selectedTitle,
saveInto: local!selectedTitle,
disabled: isnull(local!selectedDepartment)
)
}
)
)
| Solve the following leet code problem |
Configure a Boolean Checkbox
Configure a checkbox that saves a boolean (true/false) value, and validate that the user selects the checkbox before submitting a form.
This scenario demonstrates:
How to configure a checkbox field so that a single user interaction records a true or false value
| a!localVariables(
local!userAgreed,
a!formLayout(
label:"Example: Configure a Boolean Checkbox",
contents:{
a!checkboxField(
label: "Acknowledge",
choiceLabels: {"I agree to the terms and conditions."},
choiceValues: {true},
/* If local!userAgreed is false, set the value */
/* to null so that the checkbox is unchecked */
value: if(local!userAgreed, true, null),
/* We want to save a false value when the checkbox */
/* is unchecked, so we need to check whether */
/* save!value is null and update the variable if so */
saveInto: a!save(
local!userAgreed,
if(isnull(save!value), false, true)
),
required: true,
requiredMessage: "You must check this box!"
)
},
buttons:a!buttonLayout(
primaryButtons:{
a!buttonWidget(
label:"Submit",
submit: true
)
}
)
)
)
| Solve the following leet code problem |
Configure a Chart Drilldown to a Grid
Displays a column chart with aggregate data from a record type and conditionally shows a grid with filtered records when a user selects a column on the chart.
This design pattern is not recommended for offline interfaces because reflecting immediate changes in an interface based on user interaction requires a connection to the server.
This scenario demonstrates:
How to create a grid and chart using a record type as the source.
How to save a selection from the chart and filter the grid.
| a!localVariables(
local!selection,
a!sectionLayout(
contents: {
a!columnChartField(
label: "All Cases",
data: a!recordData(
recordType: recordType!Case,
filters: a!queryLogicalExpression(
operator: "AND",
filters: {
a!queryFilter(
field: recordType!Case.fields.type,
operator: "not in",
value: {"Other"}
)
},
ignoreFiltersWithEmptyValues: true
)
),
config: a!columnChartConfig(
primaryGrouping: a!grouping(
field: recordType!Case.fields.status,
alias: "status"
),
secondaryGrouping: a!grouping(
field: recordType!Case.fields.type,
alias: "type"
),
measures: {
a!measure(
function: "COUNT",
field: recordType!Case.fields.id,
alias: "id_count"
)
},
dataLimit: 100,
link: a!dynamicLink(
value: fv!selection,
saveInto: local!selection
)
),
stacking: "NONE",
colorScheme: "PARACHUTE",
showWhen: isnull(local!selection)
),
a!linkField(
labelPosition: "COLLAPSED",
links: a!dynamicLink(
label: "Back",
saveInto: a!save(
target: local!selection,
value: null
)
),
showWhen: not(isnull(local!selection))
),
a!gridField(
label: local!selection.status & " " &local!selection.type & " Cases",
labelPosition: "ABOVE",
data: a!recordData(
recordType:recordType!Case,
filters: a!queryLogicalExpression(
operator: "AND",
filters: {
a!queryFilter(
field: recordType!Case.fields.type,
operator: "=",
value: local!selection.type
),
a!queryFilter(
field: recordType!Case.fields.status,
operator: "=",
value: local!selection.status
)
},
ignorefilterswithemptyvalues: true
)
),
columns: {
a!gridColumn(
label: "Id",
sortField: recordType!Case.fields.id,
value: fv!row[recordType!Case.fields.id],
align: "END"
),
a!gridColumn(
label: "Assignee",
sortField: recordType!Case.fields.assignee,
value: a!linkField(
links: {
a!recordLink(
label: fv!row[recordType!Case.fields.assignee],
recordType: recordType!Case,
identifier: fv!identifier
)
}
)
),
a!gridColumn(
label: "Title",
sortField: recordType!Case.fields.title,
value: fv!row[recordType!Case.fields.title]
),
a!gridColumn(
label: "Priority",
sortField: recordType!Case.fields.priority,
value: fv!row[recordType!Case.fields.priority]
),
a!gridColumn(
label: "Status",
sortField: recordType!Case.fields.status,
value: fv!row[recordType!Case.fields.status]
),
a!gridColumn(
label: "Type",
sortField: recordType!Case.fields.type,
value: fv!row[recordType!Case.fields.type]
),
a!gridColumn(
label: "Date Created",
sortField: recordType!Case.fields.dateCreated,
value: fv!row[recordType!Case.fields.dateCreated],
align: "END"
),
},
showWhen: not(isnull(local!selection))
)
}
)
)
| Solve the following leet code problem |
Configure a Chart to Grid Toggle
Display a column chart with a toggle to display an alternate grid view of the data.
Display a chart with the number of tickets reported each month internally and from customers. Then add a grid to display the same data. Finally, add a link so that a user may toggle between the chart and grid views of the data. This pattern is recommended to provide a visual data display while still making the data accessible to users who employ assistive technology.
This scenario demonstrates:
How to configure alternate displays of the same data.
How to modify the expression to display a grid when the user clicks on a link toggle
This example uses a hard-coded data set. To use data from a record type, use a!queryRecordType() to populate local!ticketData and update the columns to use record type field references. See Aggregate Data and Conditionally Display in a Chart or Grid for a similar pattern using records.
| a!localVariables(
local!ticketData:{
a!map( month:"January", internalTickets:32, customerTickets:41 ),
a!map( month:"February", internalTickets:16, customerTickets:38 ),
a!map( month:"March", internalTickets:21, customerTickets:37 ),
a!map( month:"April", internalTickets:31, customerTickets:20 ),
a!map( month:"May", internalTickets:33, customerTickets:47 ),
a!map( month:"June", internalTickets:9, customerTickets:22 ),
a!map( month:"July", internalTickets:2, customerTickets:16 ),
a!map( month:"August", internalTickets:11, customerTickets:29 ),
a!map( month:"September", internalTickets:5, customerTickets:0 ),
a!map( month:"October", internalTickets:71, customerTickets:10 ),
a!map( month:"November", internalTickets:4, customerTickets:13 ),
a!map( month:"December", internalTickets:5, customerTickets:21 )
},
/* This variable is referenced in the showWhen parameters of both the grid and
the chart. */
local!showAsGrid: false,
{
a!linkField(
links:{
/* The not() function simply inverts a true or false value, making for a
simple toggle. */
a!dynamicLink(
label: "View data as a " & if(local!showAsGrid, "chart", "grid"),
value: not(local!showAsGrid),
saveInto: local!showAsGrid
)
}
),
if(local!showAsGrid,
a!gridField(
label: "Logged Defect Tickets",
data: local!ticketData,
columns: {
a!gridColumn(
label: "Month",
value: fv!row.month
),
a!gridColumn(
label: "Internal Tickets",
value: fv!row.internalTickets,
align: "END",
width: "NARROW_PLUS"
),
a!gridColumn(
label: "Customer Tickets",
value: fv!row.customerTickets,
align: "END",
width: "NARROW_PLUS"
),
a!gridColumn(
label: "Total Tickets",
value: fv!row.internalTickets + fv!row.customerTickets,
align:"END",
width: "NARROW_PLUS"
)
},
pageSize: 12
),
a!columnChartField(
label: "Logged Defect Tickets",
categories: left(local!ticketData.month, 3),
series: {
a!chartSeries(label: "Internal", data: local!ticketData.internalTickets),
a!chartSeries(label: "Customer", data: local!ticketData.customerTickets)
},
colorScheme: "PARACHUTE",
yAxisTitle: "Number of Tickets",
stacking: "NORMAL",
showLegend: true
)
)
}
)
| Solve the following leet code problem |
Configure a Dropdown Field to Save a CDT
When using a dropdown to select values from the database, or generally from an array of CDT values, configure it to save the entire CDT value rather than just a single field.
This scenario demonstrates:
How to configure a dropdown component to save a CDT value.
Notable implementation details:
Saving the entire CDT saves you from having to store the id and query the entire object separately when you need to display attributes of the selected CDT elsewhere on the form.
When you configure your dropdown, replace the value of local!foodTypes with a CDT array that is the result of a!queryEntity() or a!queryRecordType(). These functions allow you to retrieve only the fields that you need to configure your dropdown.
This technique is well suited for selecting lookup values for nested CDTs. Let's say you have a project CDT and each project can have zero, one, or many team members. Team members reference the employee CDT. Use this technique when displaying a form to the end user for selecting team members.
| a!localVariables(
local!foodTypes: {
a!map( id: 1, name: "Fruits" ),
a!map( id: 2, name: "Vegetables" )
},
local!selectedFoodType,
a!formLayout(
label: "Example: Dropdown with CDT",
contents: {
a!dropdownField(
label: "Food Type",
instructions: "Value saved: " & local!selectedFoodType,
choiceLabels: index(local!foodTypes, "name", null),
placeholder: "--- Select Food Type ---",
/* choiceValues gets the CDT/dictionary rather than the ids */
choiceValues: local!foodTypes,
value: local!selectedFoodType,
saveInto: local!selectedFoodType
)
},
buttons: a!buttonLayout(
primaryButtons: a!buttonWidget(
label: "Submit",
submit: true
)
)
)
)
| Solve the following leet code problem |
Configure a Dropdown with an Extra Option for Other
Show a dropdown that has an "Other" option at the end of the list of choices. If the user selects "Other", show a required text field.
This scenario demonstrates:
How to configure a dropdown with an appended value
How to conditionally show a field based the selection of an 'Other' option
How to save one of two values when evaluating a form through a submit button
| a)
a!localVariables(
local!departments:{"Corporate","Engineering","Finance","HR","Professional Services"},
/*
* You need separate variables to temporarily store the dropdown selection
* (local!selectedDepartment) and the value entered for "Other" (local!otherChoice).
*/
local!selectedDepartment,
local!otherChoice,
local!savedValue,
a!formLayout(
label: "Example: Dropdown with Extra Option for Other",
contents: {
a!dropdownField(
label: "Department",
instructions:"Value saved: "& local!savedValue,
/*
* Adding the "Other" option here allows you to store a separate value.
* For example, if your choiceValues are integers, you could store -1.
*/
choiceLabels: a!flatten({local!departments, "Other"}),
choiceValues: a!flatten({local!departments, "Other"}),
placeholder: "--- Select a Department ---",
value: local!selectedDepartment,
saveInto: local!selectedDepartment
),
a!textField(
label: "Other",
value: local!otherChoice,
saveInto: local!otherChoice,
required: true,
showWhen: local!selectedDepartment = "Other"
)
},
buttons: a!buttonLayout(
/*
* The Submit button saves the appropriate value to its final location
*/
primaryButtons: a!buttonWidget(
label: "Submit",
value: if(
local!selectedDepartment = "Other",
local!otherChoice,
local!selectedDepartment
),
saveInto: local!savedValue,
submit: true
)
)
)
)
b) offline mode
a!localVariables(
local!departments:{"Corporate","Engineering","Finance","HR","Professional Services"},
/*
* You need separate variables to temporarily store the dropdown selection
* (local!selectedDepartment) and the value entered for "Other" (local!otherChoice).
*/
local!selectedDepartment,
local!otherChoice,
local!savedValue,
a!formLayout(
label: "Example: Dropdown with Extra Option for Other",
contents: {
a!dropdownField(
label: "Department",
instructions:"Value saved: "& local!savedValue,
/*
* Adding the "Other" option here allows you to store a separate value.
* For example, if your choiceValues are integers, you could store -1.
*/
choiceLabels: a!flatten({local!departments, "Other"}),
choiceValues: a!flatten({local!departments, "Other"}),
placeholder: "--- Select a Department ---",
value: local!selectedDepartment,
saveInto: local!selectedDepartment
),
a!textField(
label: "Other",
value: local!otherChoice,
saveInto: local!otherChoice,
required: local!selectedDepartment = "Other"
)
},
buttons: a!buttonLayout(
/*
* The Submit button saves the appropriate value to its final location
*/
primaryButtons: a!buttonWidget(
label: "Submit",
value: if(
local!selectedDepartment = "Other",
local!otherChoice,
local!selectedDepartment
),
saveInto: local!savedValue,
submit: true
)
)
)
)
| Solve the following leet code problem |
Configure an Array Picker
Allow users to choose from a long text array using an auto-completing picker.
Also, allow users to work with user-friendly long labels but submit machine-friendly abbreviations.
|
The main expression uses a supporting rule, so let's create that first.
ucArrayPickerFilter: Scans labels that match the text entered by the user and returns a DataSubset for use in the picker component.
Create expression rule ucArrayPickerFilter with the following rule inputs:
filter (Text)
labels (Text Array)
identifiers (Text Array)
Enter the following definition for the rule:
a!localVariables(
local!matches: where(
a!forEach(
items: ri!labels,
expression: search( ri!filter, fv!item)
)
),
a!dataSubset(
data: index( ri!labels, local!matches),
identifiers: index( ri!identifiers, local!matches)
)
)
Now that we've created the supporting rule, let's move on to the main expression.
a!localVariables(
local!pickedState,
local!stateLabels: { "Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming" },
local!stateAbbreviations: { "AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "FL", "GA", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY" },
a!pickerFieldCustom(
label: "State of Residence",
instructions: "Value saved: " & local!pickedState,
placeholder: "Type to select the employee's state of residence",
maxSelections: 1,
suggestFunction: rule!ucArrayPickerFilter(
filter:_ ,
labels: local!stateLabels,
identifiers: local!stateAbbreviations
),
selectedLabels: a!forEach(
items: local!pickedState,
expression: index(local!stateLabels, wherecontains(fv!item, local!stateAbbreviations))
),
value: local!pickedState,
saveInto: local!pickedState
)
)
| Solve the following leet code problem |
Configure an Array Picker with a Show All Option
Allow users to choose from a long text array using an autocompleting picker, but also allow them to see the entire choice set using a dropdown.
Dropdowns with many choices can be a little unwieldy, but when there is doubt about even the first letters of an option they can be very useful.
This scenario demonstrates:
How to create a link that replace one component with another
How to save a value in one component and be able to see those results in another component
| Setup:
The main expression uses a supporting rule, so let's create that first.
ucArrayPickerFilter: Scans labels that match the text entered by the user and returns a DataSubset for use in the picker component.
Create expression rule ucArrayPickerFilter with the following rule inputs:
filter (Text)
labels (Text Array)
identifiers (Text Array)
Enter the following definition for the rule:
a!localVariables(
local!matches: where(
a!forEach(
items: ri!labels,
expression: search( ri!filter, fv!item)
)
),
a!dataSubset(
data: index( ri!labels, local!matches),
identifiers: index( ri!identifiers, local!matches)
)
)
Expression :
a!localVariables(
local!pickedState,
/*
* local!showPicker is used as a field toggle. When set to true, a picker and link
* will be visible. The link field with set this to false when clicked, showing a dropdown.
*/
local!showPicker: true,
local!stateLabels: { "Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming" },
local!stateAbbreviations: { "AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", "FL", "GA", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", "MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", "NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC", "SD", "TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY" },
a!sectionLayout(
contents:{
a!linkField(
links: a!dynamicLink(
label: "Show All",
value: false,
saveInto: local!showPicker,
showWhen: local!showPicker
)
),
a!pickerFieldCustom(
label: "States",
instructions: "Enter the employee's state of residence.",
maxSelections: 1,
/*
* To use with your data, replace local!stateLabels with the datapoint you wish to be displayed and
* local!stateAbbreviations with the datapoint you eventually want to save.
*/
suggestFunction: rule!ucArrayPickerFilter(filter: _, labels: local!stateLabels, identifiers: local!stateAbbreviations),
selectedLabels: a!forEach(
items: local!pickedState,
expression: index(local!stateLabels, wherecontains(fv!item, local!stateAbbreviations))
),
value: local!pickedState,
saveInto: local!pickedState,
showWhen: local!showPicker
),
a!dropdownField(
label: "States",
instructions: "Enter the employee's state of residence.",
choiceLabels: local!stateLabels,
placeholder: "Select a US state",
choiceValues: local!stateAbbreviations,
value: local!pickedState,
saveInto: local!pickedState,
showWhen: not( local!showPicker )
)
}
)
)
| Solve the following leet code problem |
Define a Simple Currency Component
Show a text field that allows the user to enter dollar amounts including the dollar symbol and thousand separators, but save the value as a decimal rather than text. Additionally, always show the dollar amount with the dollar symbol.
This scenario demonstrates:
How to configure an interface component to format a user's input
| a!localVariables(
local!amount,
a!textField(
label:"Amount in Text",
/* Instructions show the saved datatype*/
instructions: "Type of local!amount: " & typename(typeof(local!amount)),
value: a!currency(
isoCode: "USD",
value: local!amount,
format: "SYMBOL"
),
/* Instead of saving the value as text, a!save() is used to store to the desired datatype*/
saveInto: a!save(local!amount, todecimal(save!value))
)
)
| Solve the following leet code problem |
Delete Rows in a Grid
Delete one or more rows of data in a read-only grid.
This scenario demonstrates how to remove rows from a grid.
This design pattern is not recommended for offline interfaces because reflecting immediate changes in an interface based on user interaction requires a connection to the server.
| When the user clicks the REMOVE button, the selected row IDs are added to a local variable. Any ID in that variable is filtered out of the grid using a!queryFilter() within the a!recordData() function. Note that the source rows are not actually removed; the rows are just visibly removed from the grid. To actually remove the records from the source, you would want to pass those removed IDs to another function, process, or service.
SAIL code :
a!localVariables(
/* This variable stores the grid's selection. */
local!selection,
/* This variable stores the row information for the grid's selection. */
local!selectedRows,
/* This variable stores the IDs of the rows that were removed via the REMOVE button
to filter out those rows from the grid. It can also be used to pass these
IDs to a process to remove them from the source entity. */
local!removedIds,
{
a!buttonArrayLayout(
buttons: {
a!buttonWidget(
label: "REMOVE",
saveinto: {
/* Append the selected rows IDs to the local!removedIds variable. */
a!save(local!removedIds, append(local!removedIds, local!selectedRows[recordType!Employee.fields.id])),
/* Reset local!selectedRows so other rows can be removed. */
a!save(local!selectedRows, null),
/* Reset the grid selection as well. */
a!save(local!selection, null)
},
style: "OUTLINE",
/* Disable the button if local!selectedRows is empty. */
disabled: if(or(isnull(local!selectedRows),length(local!selectedRows)<1),true,false)
)
},
align: "START"
),
a!gridField(
label: "Grid with Removable Rows",
/* The recordData function allows us to filter the record data. */
data: a!recordData(
recordType: recordType!Employee,
/* This query filter applies to all rows where the row ID is found in local!removedRows. */
filters: a!queryFilter(
field: recordType!Employee.fields.id,
operator: if(isnull(local!removedIds),"not null","not in"),
value: local!removedIds
)
),
columns: {
a!gridColumn(
label: "ID",
sortField: recordType!Employee.fields.id,
value: fv!row[recordType!Employee.fields.id],
align: "END",
width: "ICON"
),
a!gridColumn(
label: "First Name",
sortField: recordType!Employee.fields.firstName,
value: fv!row[recordType!Employee.fields.firstName]
),
a!gridColumn(
label: "lastName",
sortField: recordType!Employee.fields.lastName,
value: fv!row[recordType!Employee.fields.lastName]
),
a!gridColumn(
label: "Department",
sortField: recordType!Employee.fields.department,
value: fv!row[recordType!Employee.fields.department]
),
a!gridColumn(
label: "Title",
sortField: recordType!Employee.fields.title,
value: fv!row[recordType!Employee.fields.title]
)
},
selectable: true,
selectionStyle: "ROW_HIGHLIGHT",
selectionValue: local!selection,
selectionSaveInto: {
local!selection,
/* Add row data to local!selectedRows list when that row is selected by the user. */
a!save(local!selectedRows, append(local!selectedRows,fv!selectedRows)),
/* Remove row data from local!selectedRows when that row is deselected by the user. */
a!save(local!selectedRows, difference(local!selectedRows,fv!deselectedRows))
},
showSearchBox: false,
showRefreshButton: false
)
}
)
| Solve the following leet code problem |
Disable Automatic Refresh After User Saves Into a Variable
This scenario demonstrates:
How to disable the automatic recalculation of a variable's default value once a user has edited that variable directly
|
a!localVariables(
local!startDate: today(),
local!endDateEdited: false,
local!endDate: a!refreshVariable(
value: local!startDate + 7,
refreshOnReferencedVarChange: not(local!endDateEdited)
),
{
a!dateField(
label: "Start Date",
value: local!startDate,
saveInto: local!startDate
),
a!dateField(
label: "End Date",
value: local!endDate,
saveInto: {
local!endDate,
a!save(local!endDateEdited, true)
}
)
}
)
| Solve the following leet code problem |
Display Last Refresh Time
This scenario demonstrates how to enable, track, and display the last updated time when the data in the grid refreshed on an interval, and due to a user interaction. Use this pattern when you want to let users know how fresh the data is and when it was last refreshed.
|
Solution explanation :
This pattern works by putting the recordData() function into a local variable, instead of directly into the grid, allowing the refresh variable in local!lastUpdatedAt to watch it. We use recordData() in order to take advantage of using record data in a grid which enables a refresh button. The fundamental pattern of watching another variable works just as well using a!queryEntity().
SAIL code :
=a!localVariables(
/* This refresh variable refreshes every 30 seconds to return the data from
the Employee record type. */
local!employees: a!refreshVariable(
value: a!recordData(recordType!Employee),
refreshInterval: 0.5
),
/* This refresh variable returns the current time using the now() function.
It is set to refresh whenever local!employees changes. It's also set to
refresh every 30 seconds, because if local!employees refreshes, but the
data hasn't changed, then this refresh variable wouldn't know to
refresh. */
local!lastUpdatedAt: a!refreshVariable(
value: now(),
refreshOnVarChange: local!employees,
refreshInterval: 0.5
),
a!sectionLayout(
contents:{
a!richTextDisplayField(
labelposition: "COLLAPSED",
value: {
a!richTextItem(
text: {
"Last updated at ",
text(local!lastUpdatedAt, "h:mm a")
},
color: "SECONDARY",
style: "EMPHASIS"
)
},
align: "RIGHT"
),
a!gridField(
label: "Employees",
/* The recordData() function is external to the grid so it can be
referenced by the refresh variable in local!lastUpdatedAt. */
data: local!employees,
columns: {
a!gridColumn(
label: "First Name",
sortField: recordType!Employee.fields.firstName,
value: fv!row[recordType!Employee.fields.firstName]
),
a!gridColumn(
label: "Last Name",
sortField: recordType!Employee.fields.lastName,
value: fv!row[recordType!Employee.fields.lastName]
),
a!gridColumn(
label: "Department",
sortField: "department",
value: fv!row[recordType!Employee.fields.department]
),
a!gridColumn(
label: "Title",
sortField: recordType!Employee.fields.title,
value: fv!row[recordType!Employee.fields.title]
),
a!gridColumn(
label: "Phone Number",
value: fv!row[recordType!Employee.fields.phoneNumber]
),
a!gridColumn(
label: "Start Date",
sortField: recordType!Employee.fields.startDate,
value: fv!row[recordType!Employee.fields.startDate]
)
},
rowHeader: 1
)
}
)
)
| Solve the following leet code problem |
Display Multiple Files in a Grid.
Show a dynamic number of files in a grid and edit certain file attributes.
For this recipe, were are giving our users the ability to update the file name, description, and an associative field for the file "Category". However, designers can modify this recipe to modify various types of document metadata.
This scenario demonstrates:
How to handle an array of documents in an editable grid for file verification and attribute editing
How to use a!forEach() in an interface component
|
Solution explanation :
Before we can see this recipe in the live view, we will need to create a Constant that holds an array of documents.
To do this:
Upload a few files into Appian
Create a constant of type Document named UC_DOCUMENTS and select the multiple checkbox. Select the files you just uploaded as the value.
Notes: While this recipe uses local variable for their stand-alone capability, you will typically be interaction with a CDT or datasubset data structure when working with file attributes. In these cases, the data would typically be passed in via a rule input or query.
SAIL Code :
a!localVariables(
/*
* local!files are stored in a constant here. However, this source would typically come from
* process data or queried from a relational database. local!fileMap simulates a data
* structure that would typically hold file metadata.
*/
local!files: cons!DOCUMENT_GIF_IMAGE,
local!fileMap: a!forEach(
items: local!files,
expression: a!map(
file: fv!item,
fileCategory: "",
newFileName: document(fv!item, "name"),
newFileDescription: document(fv!item, "description")
)
),
a!sectionLayout(
contents: {
a!gridLayout(
label: "Example: Display Multiple Files in a Grid",
totalCount: count(local!files),
headerCells: {
a!gridLayoutHeaderCell(label: "File"),
a!gridLayoutHeaderCell(label: "Name"),
a!gridLayoutHeaderCell(label: "Description"),
a!gridLayoutHeaderCell(label: "Category"),
a!gridLayoutHeaderCell(label: "Size (KB)", align: "RIGHT")
},
columnConfigs: {
a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 3),
a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 3),
a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 3),
a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 2),
a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 2),
},
rows: a!forEach(
items: local!fileMap,
expression: a!gridRowLayout(
contents: {
a!linkField(
/* Labels are not visible in grid cells but are necessary to meet accessibility requirements */
label: "File" & fv!index,
links: a!documentDownloadLink(
label: document(fv!item.file,"name") & "." & document(fv!item.file,"extension"),
document: fv!item.file
),
value: fv!item.newFileName,
readOnly: true
),
a!textField(
label: "File Name " & fv!index,
value: fv!item.newFileName,
saveInto: fv!item.newFileName
),
a!textField(
label: "Description " & fv!index,
value: fv!item.newFileDescription,
saveInto: fv!item.newFileDescription,
readOnly: false
),
a!dropdownField(
label: "category " & fv!index,
placeholder: "-- Please Select--",
choiceLabels: { "Resume", "Cover Letter", "Other" },
choiceValues: { "Resume", "Cover Letter", "Other" },
value: fv!item.fileCategory,
saveInto: fv!item.fileCategory
),
a!textField(
label: "title " & fv!index,
value: round(document(fv!item.file, "size") / 1000),
align: "RIGHT",
readOnly: true
)
},
id: fv!index
)
),
rowHeader: 2
),
a!textField(
label: "Value of Document Dictionary",
readOnly: true,
value: local!fileMap
)
}
)
)
| Solve the following leet code problem |
Display Processes by Process Model with Status Icons.
Use an interface to display information about instances of a specific process model.
This design pattern is not recommended for offline interfaces because reflecting immediate changes in an interface based on user interaction requires a connection to the server.
This scenario demonstrates:
How to use a!queryProcessAnalytics() to query process data
How to display process report data in a grid
How to use the process report's configured formatting to customize display
How to us a!forEach() to dynamically create a grid's columns
| Setup
For this recipe, you'll need a constant pointing to a process report and a process model that has been at least started a few times. If you don't have a process model, you can follow the Process Modeling Tutorial. Once you have some processes, you can follow these steps to create a process report with the default columns and associate it with a constant:
In the Build view of your application, click NEW > Process Report.
Select Create from scratch.
Name the report Processes for Process Model A.
Under Report Type, select Process.
Under Context Type, select Processes by process model.
Specify a folder to contain the report, and then click Create.
Open the process report in a new tab. You will see the Choose Process Models dialog open.
In the Choose Process Models dialog, select the desired process model, and then click OK.
The main expression uses two supporting constants, so let's create them first.
UC_PROCESSES_FOR_PM_REPORT: Constant of type Document whose value is Processes for Process Model A.
UC_PROCESS_MODEL: Constant of type Process Model whose value is the process you created
SAIL Code :
a!localVariables(
local!pagingInfo: a!pagingInfo(
startIndex: 1,
batchSize: -1
),
local!report: a!queryProcessAnalytics(
report: cons!UC_PROCESSES_FOR_PM_REPORT,
contextProcessModels: {
cons!UC_PROCESS_MODEL
},
query: a!query(
pagingInfo: local!pagingInfo
)
),
a!gridField(
label: local!report.name,
instructions: local!report.description,
data: local!report.data,
columns: a!forEach(
items: local!report.columnConfigs,
expression: a!gridColumn(
label: fv!item.label,
sortField: fv!item.field,
value: if(
fv!item.configuredFormatting = "PROCESS_STATUS_ICON",
a!imageField(
images: choose(
/*Process status go from 0-4, so add 1 to index into the choose list */
1 + tointeger(index(fv!row, fv!item.field, {})),
a!documentImage(
document: a!iconIndicator( icon: "PROGRESS_RUNNING" ),
altText: "Active",
caption: "Active"
),
a!documentImage(
document: a!iconIndicator( icon: "STATUS_OK" ),
altText: "Completed",
caption: "Completed"
),
a!documentImage(
document: a!iconIndicator( icon: "PROGRESS_PAUSED" ),
altText: "Paused",
caption: "Paused"
),
a!documentImage(
document: a!iconIndicator( icon: "STATUS_NOTDONE" ),
altText: "Cancelled",
caption: "Cancelled"
),
a!documentImage(
document: a!iconIndicator( icon: "STATUS_ERROR" ),
altText: "Paused By Exception",
caption: "Paused By Exception"
)
) ),
index(fv!row, fv!item.field)
)
)
),
rowHeader: 1,
pageSize: 20
)
)
| Solve the following leet code problem |
Display a User's Tasks in a Grid With Task Links.
Display the tasks for a user in a Read-Only Grid and allow them to click on a task to navigate to the task itself.
This design pattern is not recommended for offline interfaces because reflecting immediate changes in an interface based on user interaction requires a connection to the server.
This scenario demonstrates:
How to use a!queryProcessAnalytics() to query task data
How to display a grid based on a process report's configuration
How to use the process report's configured formatting in SAIL
How to convert the process report's configured drilldown to interface links
|
Setup
For this recipe, you'll need a constant pointing to a task report. Follow these steps to create a task report with the default columns and associate it with a constant:
In the Build view of your application, click NEW > Process Report.
Select Create from scratch.
Name the report Tasks for User A, and provide a description that will be displayed as the label and instructions of the grid.
Under Report Type, select Task.
Under Context Type, select Tasks by owner.
Specify a folder to contain the report, and then click Create & Edit.
The process report opens in a new tab.
In the toolbar, click Edit.
In the Report Options dialog, click the Data tab.
Click the Name link.
Check the Link to more information checkbox and from the Link to dropdown list, select Task Details.
Click Save.
Save the report by clicking Save in the toolbar.
The main expression uses a supporting constant constant, so let's create them first.
UC_TASKS_FOR_USER_REPORT: Constant of type Document whose value is Tasks for User A
Now that we've created the supporting rules, let's move on to the main expression.
Sail Code:
a!localVariables(
local!pagingInfo: a!pagingInfo(
startIndex: 1,
batchSize: -1
),
local!report: a!queryProcessAnalytics(
report: cons!UC_TASKS_FOR_USER_REPORT,
query: a!query(pagingInfo: local!pagingInfo)
),
a!gridField(
label: local!report.name,
instructions: local!report.description,
data: local!report.data,
columns:
a!forEach(
items: local!report.columnConfigs,
expression: a!gridColumn(
label: fv!item.label,
sortField: fv!item.field,
align: if(fv!item.configuredFormatting = "DATE_TIME", "END", "START"),
value: if(
fv!item.configuredFormatting = "TASK_STATUS",
index(
{
"Assigned",
"Accepted",
"Completed",
"Not Started",
"Cancelled",
"Paused",
"Unattended",
"Aborted",
"Cancelled By Exception",
"Submitted",
"Running",
"Error"
},
/* Task status ids start with 0, so add one to reach the first index */
tointeger(index(fv!row, tointeger(fv!item.field) + 1, -1 )),
"Other"
),
if(
fv!item.configuredDrilldown = "TASK_DETAILS",
a!linkField(
links: a!processTaskLink(
label: index(fv!row, fv!item.field, {}),
task: index(fv!row, fv!item.drilldownField, {})
)
),
index(fv!row, fv!item.field, {})
)
)
)
),
rowHeader: 1,
pageSize: 20
)
)
| Solve the following leet code problem |
Dynamically Show Sales by Product Category Compared to Total Sales.
This pattern illustrates how to create an area chart that dynamically displays sales generated by product category compared to total sales. This pattern also provides a sample scenario to show how you can take common business requirements and quickly turn them into a report.
You'll notice that this pattern provides more than just an expression, it shows you the fastest way to build reports in Design Mode. To get the most out of this pattern, follow the steps in Create this pattern to learn how to build advanced reports using the latest low-code features.
Scenario
Inventory managers at the Appian Retail company want to know how monthly sales were divided among the different product categories to see how their line of products impact overall sales. Since each inventory manager is responsible for a certain product category, they want this report to help them determine if they need to change their inventory strategy to follow sales trends.
To allow different inventory managers to view their own product category sales, you'll use the pattern on this page to create an area chart that can be filtered by product category. This way, users can see their monthly sales for the selected category compared to the total sales generated each month.
| Setup
This pattern uses data from the Appian Retail application, available for free in Appian Community Edition. To follow along with this pattern, log in to Appian Community to request the latest Appian Community Edition site.
If you do not see the Appian Retail application available in your existing Appian Community Edition, you can request a new Appian Community Edition to get the latest application contents available.
This pattern will use data from the following record types in the Appian Retail application:
1) Order record type: Contains order information like the order number, date, status, and whether it was purchased online or in stores. For example, order number SO43659 was purchased in stores on 5/31/2019 and the order is closed.
2) Order Detail record type: Contains specific order details like the number of order items, order totals, promo codes applied, and products. For example, the order above contained one product that cost $2,024.99.
3) Product Category record type: Contains product categories. For example, Bikes.
Step 1: Create an area chart with total sales per monthCopy link to clipboard
First, we'll create an area chart that shows the total sales generated each month in 2021.
To create the area chart:
In the Appian Retail application, go to the Build view.
Click NEW > Interface.
Configure the interface properties and click CREATE.
From the PALETTE, drag an AREA CHART component into the interface.
From Data Source, select RECORD TYPE and search for the Order record type.
For Primary Grouping, keep the default field selection orderDate.
Click the pencil icon next to the Primary Grouping to change the format of the date values. This will allow you to read the dates in an easier format:
For Time Interval, select Month.
For Format Value, use a pre-defined format to display the abbreviated month and year. For example, Nov 2021.
Return to the Area Chart component configuration.
Click the pencil icon next to the Measure to configure the chart's aggregation:
For Label, enter Total Sales.
For Aggregation Function, select Sum of.
For Field, remove the existing field. Then, use the dropdown to hover over the orderDetail relationship and select the lineTotal field. The field will display as orderDetail.lineTotal.
Return to the Area Chart component configuration.
Click FILTER RECORDS.
Click Add Filter and configure the following conditions:
For Field, select orderDate.
For Condition, select Date Range.
For Value, use the context menu () to select Expression.
Click null to edit the expression.
Replace the existing value with the following expression:
{
todatetime("01/01/2021"),
todatetime("12/31/2021")
}
Click OK.
Click OK to close the dialog.
Step 2: Add a second measure with a filterCopy link to clipboard
Now, we're going to add a second measure to the area chart. This measure will include a filter so it only displays the sum of sales from orders that have at least one item from the Bikes category.
To add the second measure:
On the area chart, click ADD MEASURE.
Click the pencil icon next to the new Measure to configure the second aggregation:
For Label, enter Product Category: Bikes.
For Aggregation Function, select Sum of.
For Field, use the dropdown to hover over the orderDetail relationship and select the lineTotal field. The field will display as orderDetail.lineTotal.
Click + ADD FILTERS.
Click Add Filter and configure following:
For Field, use the dropdown to hover over product > productSubcategory > productCategory and select the name field. The field will display as product.productSubcategory.productCategory.name.
For Condition, leave the default selection of equal to.
For Value, enter Bikes.
Click OK.
Return to the Area Chart component configuration.
For Label, enter Monthly Sales in 2021.
For Stacking, select None.
Step 3: Add a dropdown componentCopy link to clipboard
Since inventory managers want to see sales trends for each product category, not just bikes, you'll add a filter that lets users change which product category is displayed in the chart.
To dynamically filter the chart, you'll add a dropdown component and configure a local variable so the selected dropdown option will filter the chart. Let's start by adding the dropdown component.
To add the dropdown component:
From the PALETTE, drag the COLUMNS component onto your interface above the area chart.
From the PALETTE, drag the DROPDOWN component into the left column.
For the dropdown's Label, enter Product Categories.
Hover over Choice Labels and click Edit as Expression . The Choice Labels dialog appears.
Delete the default values in the dialog.
Click Create Constant create constant icon and configure the following values:
For Name, enter AR_CATEGORIES.
For Type, select Text.
Select the Array (multiple values) checkbox.
For Values, enter the category options. Separate each category by a line break, but do not include spaces, commas, or quotations:
Bikes
Accessories
Clothing
Components
Leave the other fields as default.
Click CREATE. The constant cons!AR_CATEGORIES appears in the Choice Labels dialog.
Click OK.
Note: After you change the Choice Label to use the constant, an error will appear. This is expected since the Choice Label and Choice Values fields currently have different values. The error will resolve itself when you change the Choice Values field to use the same constant.
Hover over Choice Values and click Edit as Expression . The Choice Values dialog appears.
Delete the default values in the Choice Values dialog and enter cons!AR_CATEGORIES.
Click OK.
Step 4: Add a local variable to filter the chart based on the dropdown selectionCopy link to clipboard
Now that you have a dropdown component, you need to configure a local variable to save the selected dropdown value. After, you'll configure a filter on the chart to only display sales by the selected value.
Since you want a category selection to appear on the chart when it first loads, you’ll also add a default value to your local variable.
To add the local variable:
In your interface, click EXPRESSION in the title bar.
Modify the Interface Definition by making the highlighted changes to the expression:
+ a!localVariables(
+ local!category: "Bikes",
{
a!columnsLayout(
columns: {
a!columnLayout(
contents: {
a!dropdownField(
label: "Product Categories",
labelPosition: "ABOVE",
placeholder: "--- Select a Value ---",
choiceLabels: cons!AR_CATEGORIES,
choiceValues: cons!AR_CATEGORIES,
saveInto: {},
searchDisplay: "AUTO",
validations: {}
)
}
),
a!columnLayout(contents: {}),
a!columnLayout(contents: {})
}
),
a!lineChartField(
data: a!recordData(
recordType: 'recordType!{ad898682-e651-4b2d-af67-47c1fcb1171f}Order',
filters: a!queryLogicalExpression(
operator: "AND",
filters: {
a!queryFilter(
field: 'recordType!{ad898682-e651-4b2d-af67-47c1fcb1171f}Order.fields.{fbcc99f6-1ddf-4923-903b-18122a1737c6}orderDate',
operator: "between",
value: /* Trailing 12 Months */toDatetime(
{
eomonth(today(), - 13) + 1,
eomonth(today(), - 1) + 1
}
)
)
},
ignoreFiltersWithEmptyValues: true
)
),
config: a!lineChartConfig(
primaryGrouping: a!grouping(
field: 'recordType!{ad898682-e651-4b2d-af67-47c1fcb1171f}Order.fields.{fbcc99f6-1ddf-4923-903b-18122a1737c6}orderDate',
alias: "orderDate_month_primaryGrouping",
interval: "MONTH_SHORT_TEXT"
),
measures: {
a!measure(
label: "Total Sales",
function: "SUM",
field: 'recordType!{ad898682-e651-4b2d-af67-47c1fcb1171f}Order.relationships.{0bde4028-fd7a-411f-97ad-7ad5b84e0d18}orderDetail.fields.{db456082-5f77-4765-bc3e-f662651e0d52}lineTotal',
alias: "lineTotal_sum_measure1"
),
a!measure(
label: "Product Category: Bikes",
function: "SUM",
field: 'recordType!{ad898682-e651-4b2d-af67-47c1fcb1171f}Order.relationships.{0bde4028-fd7a-411f-97ad-7ad5b84e0d18}orderDetail.fields.{db456082-5f77-4765-bc3e-f662651e0d52}lineTotal',
filters: a!queryLogicalExpression(
operator: "AND",
filters: {
a!queryFilter(
field: 'recordType!{bec4a875-9980-4bbf-a38c-c492ebed065a}Order Detail.relationships.{eee8c0a6-46b0-4cb7-9faf-be492400cc41}product.relationships.{d3a62d4a-3268-48dc-9563-3b99c33715d1}productSubcategory.relationships.{61e25c34-c4ba-4315-8da4-b2ed06d9b5ae}productCategory.fields.{963f051f-baea-4a23-8481-e365bf972a74}name',
operator: "=",
value: "Bikes"
)
},
ignoreFiltersWithEmptyValues: true
),
alias: "lineTotal_sum_measure2"
)
},
dataLimit: 100
),
label: "Monthly Sales ",
labelPosition: "ABOVE",
showLegend: true,
showTooltips: true,
colorScheme: "CLASSIC",
height: "MEDIUM",
xAxisStyle: "STANDARD",
yAxisStyle: "STANDARD",
refreshAfter: "RECORD_ACTION"
)
}
+ )
Now that you have a local variable to store the selected category, we can update the dropdown component to use local!category as the saveInto value, and add a filter using local!category to filter the chart by category.
To use the local variable to filter the chart:
In the a!dropdownField() configuration (line 8), add the following parameter and values highlighted below:
a!dropdownField(
label: "Product Categories",
labelPosition: "ABOVE",
placeholder: "--- Select a category ---",
choiceLabels: cons!AR_CATEGORIES,
choiceValues: cons!AR_CATEGORIES,
+ value: local!category,
saveInto: local!category,
searchDisplay: "AUTO",
validations: {}
)
In the a!areaChartConfig() configuration (line 47), update the following values highlighted below:
...
config: a!areaChartConfig(
primaryGrouping: a!grouping(
field: 'recordType!{ad898682-e651-4b2d-af67-47c1fcb1171f}Order.fields.{fbcc99f6-1ddf-4923-903b-18122a1737c6}orderDate',
alias: "orderDate_month_primaryGrouping",
interval: "MONTH_TEXT"
),
measures: {
a!measure(
label: "Total Sales",
function: "SUM",
field: 'recordType!{ad898682-e651-4b2d-af67-47c1fcb1171f}Order.relationships.{0bde4028-fd7a-411f-97ad-7ad5b84e0d18}orderDetail.fields.{db456082-5f77-4765-bc3e-f662651e0d52}lineTotal',
alias: "lineTotal_sum_measure1"
),
a!measure(
label: "Product Category: " & local!category,
function: "SUM",
field: 'recordType!{ad898682-e651-4b2d-af67-47c1fcb1171f}Order.relationships.{0bde4028-fd7a-411f-97ad-7ad5b84e0d18}orderDetail.fields.{db456082-5f77-4765-bc3e-f662651e0d52}lineTotal',
filters: a!queryLogicalExpression(
operator: "AND",
filters: {
a!queryFilter(
field: 'recordType!{bec4a875-9980-4bbf-a38c-c492ebed065a}Order Detail.relationships.{eee8c0a6-46b0-4cb7-9faf-be492400cc41}product.relationships.{d3a62d4a-3268-48dc-9563-3b99c33715d1}productSubcategory.relationships.{61e25c34-c4ba-4315-8da4-b2ed06d9b5ae}productCategory.fields.{963f051f-baea-4a23-8481-e365bf972a74}name',
operator: "=",
value: local!category
)
},
ignoreFiltersWithEmptyValues: true
),
alias: "lineTotal_sum_measure2"
)
...
Click SAVE CHANGES.
Full SAIL Code :
a!localVariables(
local!category: "Bikes",
{
a!columnsLayout(
columns: {
a!columnLayout(
contents: {
a!dropdownField(
label: "Product Categories",
labelPosition: "ABOVE",
placeholder: "--- Select a Value ---",
choiceLabels: cons!AR_CATEGORIES,
choiceValues: cons!AR_CATEGORIES,
value: local!category,
saveInto: local!category,
searchDisplay: "AUTO",
validations: {}
)
}
),
a!columnLayout(contents: {}),
a!columnLayout(contents: {})
}
),
a!areaChartField(
data: a!recordData(
recordType: 'recordType!{ad898682-e651-4b2d-af67-47c1fcb1171f}Order',
filters: a!queryLogicalExpression(
operator: "AND",
filters: {
a!queryFilter(
field: 'recordType!{ad898682-e651-4b2d-af67-47c1fcb1171f}Order.fields.{fbcc99f6-1ddf-4923-903b-18122a1737c6}orderDate',
operator: "between",
value: {
todatetime("01/01/2021"),
todatetime("12/31/2021")
}
)
},
ignoreFiltersWithEmptyValues: true
)
),
config: a!areaChartConfig(
primaryGrouping: a!grouping(
field: 'recordType!{ad898682-e651-4b2d-af67-47c1fcb1171f}Order.fields.{fbcc99f6-1ddf-4923-903b-18122a1737c6}orderDate',
alias: "orderDate_month_primaryGrouping",
interval: "MONTH_SHORT_TEXT"
),
measures: {
a!measure(
label: "Total Sales",
function: "SUM",
field: 'recordType!{ad898682-e651-4b2d-af67-47c1fcb1171f}Order.relationships.{0bde4028-fd7a-411f-97ad-7ad5b84e0d18}orderDetail.fields.{db456082-5f77-4765-bc3e-f662651e0d52}lineTotal',
alias: "lineTotal_sum_measure1"
),
a!measure(
label: "Product Category: " & local!category,
function: "SUM",
field: 'recordType!{ad898682-e651-4b2d-af67-47c1fcb1171f}Order.relationships.{0bde4028-fd7a-411f-97ad-7ad5b84e0d18}orderDetail.fields.{db456082-5f77-4765-bc3e-f662651e0d52}lineTotal',
filters: a!queryLogicalExpression(
operator: "AND",
filters: {
a!queryFilter(
field: 'recordType!{bec4a875-9980-4bbf-a38c-c492ebed065a}Order Detail.relationships.{eee8c0a6-46b0-4cb7-9faf-be492400cc41}product.relationships.{d3a62d4a-3268-48dc-9563-3b99c33715d1}productSubcategory.relationships.{61e25c34-c4ba-4315-8da4-b2ed06d9b5ae}productCategory.fields.{963f051f-baea-4a23-8481-e365bf972a74}name',
operator: "=",
value: local!category
)
},
ignoreFiltersWithEmptyValues: true
),
alias: "lineTotal_sum_measure2"
)
},
dataLimit: 100,
showIntervalsWithNoData: true
),
label: "Monthly Sales in 2021",
labelPosition: "ABOVE",
stacking: "NONE",
showLegend: true,
showTooltips: true,
colorScheme: "CLASSIC",
height: "MEDIUM",
xAxisStyle: "STANDARD",
yAxisStyle: "STANDARD",
refreshAfter: "RECORD_ACTION"
)
}
)
| Solve the following leet code problem |
Expand/Collapse Rows in a Tree Grid
Create a grid that shows hierarchical data and allows users to dynamically expand and collapse rows within the grid.
This scenario demonstrates:
How to use the rich text display component inside an editable grid to create a tree grid.
How to use a rich text display component to create a dynamic link used to expand and collapse the rows in an editable grid.
How to create a rich text bulleted list within a rich text display component inside each collapsible row in the tree grid.
| SetupCopy link to clipboard
For this recipe, you'll need two Data Store Entities that are populated with data:
Create a custom data type called PurchaseRequest with the following fields:
id (Number (Integer))
summary (Text)
Designate the id field as the primary key and set to generate value.
See also: Primary Keys
Save and publish the CDT.
Create a custom data type called PurchaseRequestItem with the following fields:
id (Number (Integer))
summary (Text)
qty (Number (Integer))
unitPrice (Number (Decimal))
purchaseRequest (PurchaseRequest)
Designate the id field as the primary key and set to generate value.
Save and publish the CDT.
Create a Data Store called "Purchase Request" with two entities, one of each data type that was just created:
PurchaseRequests (PurchaseRequest)
PurchaseRequestItems (PurchaseRequestItem)
Insert the following values into PurchaseRequest:
id summary
1 PR 1
2 PR 2
Insert the following values into PurchaseRequestItem:
id summary qty unitPrice purchaseRequest.id
1 Item 1 2 10 1
2 Item 2 3 50 1
3 Item 3 1 100 1
4 Item 4 3 75 2
5 Item 5 10 25 2
Now that we have the data, let's create a couple of supporting constants:
PR_ENTITY: A constant of type Data Store Entity with value PurchaseRequests.
PR_ITEM_ENTITY: A constant of type Data Store Entity with value PurchaseRequestItems.
Now that we have created all of the supporting objects, let's move on to the main expression.
SAIL Code:
a!localVariables(
local!prs: a!queryEntity(
entity: cons!PR_ENTITY,
query: a!query(
/* To return all fields, leave the selection parameter blank. `*/
/*`If you are not displaying all fields, use the selection `*/
/*` parameter to only return the necessary fields */
pagingInfo: a!pagingInfo(startIndex: 1, batchSize: -1)
)
).data,
local!items: a!queryEntity(
entity: cons!PR_ITEM_ENTITY,
query: a!query(
pagingInfo: a!pagingInfo(startIndex: 1, batchSize: -1)
)
).data,
a!gridLayout(
headerCells: {
a!gridLayoutHeaderCell(label: "Summary"),
a!gridLayoutHeaderCell(label: "Qty", align: "RIGHT"),
a!gridLayoutHeaderCell(label: "Unit Price", align: "RIGHT"),
a!gridLayoutHeaderCell(label: "Total Price", align: "RIGHT")
},
columnConfigs: {
a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 4),
a!gridLayoutColumnConfig(width: "DISTRIBUTE"),
a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 2),
a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight: 2)
},
rowHeader: 1,
rows: a!forEach(
items: local!prs,
expression: a!localVariables(
local!expanded: false,
local!itemsForPr: index(
local!items,
/* Must cast to integer because a!queryEntity() returns a dictionary */
wherecontains(tointeger(fv!item.id), local!items.purchaseRequest.id),
{}
),
local!totalPrice: sum(
a!forEach(
items: local!itemsForPr,
expression:
tointeger(fv!item.qty) * todecimal(fv!item.unitPrice)
)
),
{
a!gridRowLayout(
contents: {
a!richTextDisplayField(
label: "Summary " & fv!index,
value: {
if(
length(local!itemsForPr)=0,
fv!item.summary,
a!richTextItem(
text: if(local!expanded, "-", "+") &" "& fv!item.summary,
link: a!dynamicLink(
value: not(local!expanded),
saveInto: local!expanded
)
)
)
}
),
a!textField(
label: "Qty " & fv!index,
readOnly: true
),
a!textField(
label: "Unit Price " & fv!index,
readOnly: true
),
a!textField(
label: "Total Price " & fv!index,
value: a!currency(
isoCode: "USD",
value: local!totalPrice
),
readOnly: true,
align: "RIGHT"
)
}
),
if(
local!expanded,
a!forEach(
items: local!itemsForPr,
expression: a!gridRowLayout(contents: {
a!richTextDisplayField(
label: "Item Summary " & fv!index,
value: a!richTextBulletedList(
items: fv!item.summary
)
),
a!integerField(
label: "Item Qty " & fv!index,
value: fv!item.qty,
readOnly: true,
align: "RIGHT"
),
a!textField(
label: "Item Unit Price " & fv!index,
value: a!currency(
isoCode: "USD",
value: fv!item.unitPrice)
,
readOnly: true,
align: "RIGHT"
),
a!textField(
label: "Item Total Price " & fv!index,
value: a!currency(
isoCode: "USD",
value: tointeger(fv!item.qty) * todecimal(fv!item.unitPrice)
),
readOnly: true,
align: "RIGHT"
)
})
),
{}
)
}
)
)
)
)
Notice that we used a rich text display component to create a dynamic link used to expand and collapse the item rows for each purchase request. Alternatively, we could have used a link component containing the same dynamic link. The rich text display component would be useful here if a rich text style (e.g. underline) needed to be applied to the purchase request summary or if the summary needed to be a combination of links and normal text.
The bullet appearing in front of each item summary is made possible by using a rich text bulleted list within a rich text display component. See also: Rich Text
We left the selection parameter blank in our a!query()function because we wanted to return all fields of the entities that we were querying.
| Solve the following leet code problem |
Filter the Data in a Grid
Configure a user filter for your read-only grid that uses a record type as the data source. When the user selects a value to filter by, update the grid to show the result.
This design pattern is not recommended for offline interfaces because reflecting immediate changes in an interface based on user interaction requires a connection to the server.
| Filter the rows in a grid
User filters on your read-only grid allow users to select a filter and return only the records that match the filter value. When you use a record type as the data source for your read-only grid, there are two ways to configure user filters on the grid.
In design mode, you can quickly and easily bring any user filters configured in the record type into your grid. In expression mode, you can use the filter parameter in the a!recordData() function to manually configure a user filter for a specific grid. This type of user filter is considered single-use because it is not configured in the record type.
The patterns on this page demonstrate both methods for configuring user filters on your grid.
Applying a filter from the record type
Walk through the steps below to bring a user filter configured on a record type into your read-only grid.
Replace the Employee record type used in this example with a record type in your environment. Be sure there is at least one user filter configured on your record type.
To add a user filter from your record type to the grid:
Note: This example will not evaluate in your test interface and should only be used as a reference.
In the Build view of your application, click NEW > Interface.
From the COMPONENTS PALETTE, drag and drop the READ-ONLY GRID component onto your interface.
From the DATA section in the COMPONENT CONFIGURATION pane, select Record Type as your Data Source.
In the Search record types field, enter the Employee record type. Note: Replace Employee with the name of your record type.
From the RECORD LIST section in the COMPONENT CONFIGURATION pane, select the Department user filter in the User Filter dropdown. Note: Replace Department with the name of the user filter configured on your record type.
The Department user filter is applied to the grid. When the user selects a specific department, the grid will only display the records that match the filter value.
/SAIL Recipe Filter Data in a Grid
You can test the grid by selecting a title from the filter dropdown. Notice that only the employee records that match the selected title are visible in the grid. The result displays on page 1 even if the user was previously on a different page number.
See Create a Record Type for more information about configuring user filters on a record type and Configuring the Read-Only Grid for more information about configuring a read-only grid.
Manually creating a filter on the grid
This pattern demonstrates how to use a!gridField() to configure a read-only grid and manually configure a user filter dropdown for the grid.
Use the pattern in this example as a template to configure a user filter for a specific grid only. If you plan to reuse the user filter across multiple read-only grids, it is best practice to configure the user filter in the record type. This allows you to quickly and easily bring the filter into any grid that uses the record type as the data source.
ExpressionCopy link to clipboard
The expression pattern below shows you how to:
Manually configure a user filter for a specific grid only.
Use a!localVariables to store the filter value a user selects.
Use a!dropdownField() to configure a filter dropdown for the grid.
SAIL Code :
a!localVariables(
/* In your application, replace the values used in local!titles with a
* constant that stores the filter values you want to use in your grid.
* Then use cons!<constant name> to reference the constant in
* local!titles. */
local!titles: {"Analyst", "Consultant", "Director", "Manager", "Sales Associate", "Software Engineer"},
/* Use a local variable to hold the name of the title filter the user
* selects in the filter dropdown. This example, uses
* local!selectedTitle */
local!selectedTitle,
a!sectionLayout(
contents: {
a!columnsLayout(
columns: {
a!columnLayout(
contents: {
a!richTextDisplayField(
label: "",
labelPosition: "COLLAPSED",
value: {
a!richTextItem(
/* We used ampersand (&) to concatenate the title
* text we want to display at the top of the grid.
* When the user selects a title filter in the
* dropdown list, the grid will display "ALL
* <local!selectedTitle> EMPLOYEES". If no filter
* is selected, the grid * will display "ALL
* EMPLOYEES". */
text: {
"All"& " "&if(isnull(local!selectedTitle),"EMPLOYEE", upper(local!selectedTitle))&"S"
},
size: "MEDIUM_PLUS",
style: {
"STRONG"
}
)
}
),
a!dropdownField(
label: "Title",
labelPosition: "ABOVE",
placeholder: "-- Filter By Title --",
choiceLabels: local!titles,
choiceValues: local!titles,
value: local!selectedTitle,
saveInto: local!selectedTitle
)
},
width: "MEDIUM"
)
}
),
a!gridField(
labelPosition: "ABOVE",
data: a!recordData(
recordType: recordType!Employee,
filters: a!queryFilter(
field: recordType!Employee.fields.title,
operator: if(isnull(local!selectedTitle), "not null", "="),
value: local!selectedTitle
)
),
columns: {
a!gridColumn(
label: "Name",
sortField: recordType!Employee.fields.lastName,
value: a!linkField(
links: a!recordLink(
label: fv!row[recordType!Employee.fields.firstName] & " " & fv!row[recordType!Employee.fields.lastName],
recordType: {
recordType!Employee
},
identifier: fv!row[recordType!Employee.fields.lastName]
)
),
width: "1X"
),
a!gridColumn(
label: "Title",
sortField: recordType!Employee.fields.title,
value: fv!row[recordType!Employee.fields.title],
width: "1X"
),
a!gridColumn(
label: "Department",
sortField: recordType!Employee.fields.department,
value: fv!row[recordType!Employee.fields.department],
width: "1X"
)
},
pageSize: 10,
showSearchBox: false,
showRefreshButton: false,
)
}
)
)
| Solve the following leet code problem |
Filter the Data in a Grid Using a Chart.
Display an interactive pie chart with selectable sections so that a user may filter the results in a grid.
This design pattern is not recommended for offline interfaces because reflecting immediate changes in an interface based on user interaction requires a connection to the server.
This interface has two main components: (1) a grid listing all of a company’s employees, and (2) a pie chart with dynamic link sections capable of filtering the grid by department.
This scenario demonstrates:
How to use an expression to add links to each slice of the pie chart and use those links to filter grid data.
How to use multiple datasubsets.
| Create this patternCopy link to clipboard
This recipe uses references to record types and record fields. To use this recipe, you will need to update the references to record types and record fields in your application.
SAIL Code:
a!localVariables(
local!chartDataSubset: a!queryRecordType(
recordType: recordType!Employee,
/* Grouping on department then counting the total ids in that group
for the pie chart to size. This returns an array of departments
with the total number of employees in that department. It looks
like this: { {department:Engineering, id: 6}...} */
fields: a!aggregationFields(
groupings: a!grouping(
field: recordType!Employee.fields.department,
alias: "department"
),
measures: a!measure(
field: recordType!Employee.fields.id,
function: "COUNT",
alias: "id_measure"
)
),
pagingInfo: a!pagingInfo(
startIndex: 1,
batchSize: 5000,
sort: a!sortInfo(
field: "department",
ascending: true
)
)
),
/* local!selectedDepartment holds the name of the selected pie chart section. */
local!selectedDepartment,
a!sectionLayout(
contents: {
a!pieChartField(
series: a!forEach(
items: local!chartDataSubset.data,
expression: a!chartSeries(
label: fv!item.department,
data: fv!item.id,
links: a!dynamicLink(
/* The dynamic link stores the department value into local!selectedDepartment. */
value: fv!item.department,
saveInto: local!selectedDepartment
)
)
),
colorScheme: "MIDNIGHT"
),
a!linkField(
labelPosition: "COLLAPSED",
links: a!dynamicLink(
label: "Show all employees",
value: null,
saveInto: { local!selectedDepartment }
),
showWhen: not(isnull(local!selectedDepartment))
),
a!gridField(
label: if(
isnull(local!selectedDepartment),
"All Employees",
"Employees in " & local!selectedDepartment
),
emptyGridMessage: "No employees meet this criteria",
data: a!recordData(
recordType: recordType!Employee,
/* Filter the department column based on the value of local!selectedDepartment. */
filters: a!queryLogicalExpression(
operator: "AND",
filters: a!queryFilter(
field: recordType!Employee.fields.department,
operator: "=",
value: local!selectedDepartment
),
ignorefilterswithemptyvalues: true
)
),
columns: {
a!gridColumn(
label: "First Name",
sortField: recordType!Employee.fields.firstName,
value: fv!row[recordType!Employee.fields.firstName]
),
a!gridColumn(
label: "Last Name",
sortField: recordType!Employee.fields.lastName,
value: fv!row[recordType!Employee.fields.lastName]
),
a!gridColumn(
label: "Title",
sortField: recordType!Employee.fields.title,
value: fv!row[recordType!Employee.fields.title]
)
}
)
}
)
)
Notice that when the grid is filtered, we are not querying the department field. This allows us to only query the data that we plan on displaying in the grid.
| Solve the following leet code problem |
Format the User's Input
Format the user's input as a telephone number in the US and save the formatted value, not the user's input.
This expression uses the text() function to format the telephone number. You may choose to format using your own rule, so you would create the supporting rule first, and then create an interface with the main expression.
This scenario demonstrates:
How to configure a field to format a user's input
|
SAIL Code:
a!localVariables(
local!telephone,
a!textField(
label: "Employee Telephone Number",
instructions: "Value saved: " & local!telephone,
value: local!telephone,
saveInto: a!save(
local!telephone,
text(save!value, "###-###-####;###-###-####")
)
)
)
| Solve the following leet code problem |
Limit the Number of Rows in a Grid That Can Be Selected
Limit the number of rows that can be selected to an arbitrary number.
This scenario demonstrates:
How to configure grid selection in a Read-Only Grid.
How to limit selection to an arbitrary number.
How to remove selections without clicking through pages.
| a!localVariables(
local!selection,
/* This is the maximum number of rows you can select from the grid. */
local!selectionLimit: 2,
/*This variable would be used to pass the full rows of data on the selected items out of this interface, such as to a process model. */
local!selectedEmployees,
{
a!columnsLayout(
columns: {
a!columnLayout(
contents: {
a!gridField(
label: "Employees",
labelPosition: "ABOVE",
instructions: "Select up to " & local!selectionLimit & " employees.",
data: recordType!Employee,
columns: {
a!gridColumn(
label: "ID",
sortField: "id",
value: fv!row[recordType!Employee.fields.id],
width: "ICON"
),
a!gridColumn(
label: "First Name",
sortField: "firstName",
value: fv!row[recordType!Employee.fields.firstName]
),
a!gridColumn(
label: "Last Name",
sortField: "lastName",
value: fv!row[recordType!Employee.fields.lastName]
),
a!gridColumn(
label: "Phone Number",
sortField: "phoneNumber",
value: fv!row[recordType!Employee.fields.phoneNumber]
)
},
pagesize: 10,
selectable: true,
selectionstyle: "ROW_HIGHLIGHT",
/* This is where we pass the maximum number of rows you can select into the grid. */
maxSelections: local!selectionLimit,
selectionvalue: local!selection,
showSelectionCount: "ON",
selectionSaveInto: {
local!selection,
/*This save adds the full rows of data for items selected in the most recent user interaction to local!selectedEmployees. */
a!save(
local!selectedEmployees,
append(
local!selectedEmployees,
fv!selectedRows
)
),
/*This save removes the full rows of data for items deselected in the most recent user interaction to local!selectedEmployees. */
a!save(
local!selectedEmployees,
difference(
local!selectedEmployees,
fv!deselectedRows
)
)
}
),
},
width: "WIDE"
),
a!columnLayout(
contents: {
a!sectionLayout(
label: "Selected Employees",
contents: {
a!richTextDisplayField(
value: if(
or(
isnull(local!selectedEmployees),
length(local!selectedEmployees) = 0
),
a!richTextItem(text: "None", style: "EMPHASIS"),
{}
),
marginBelow: "NONE"
),
a!forEach(
local!selectedEmployees,
a!cardLayout(
contents: {
a!sideBySideLayout(
items: {
a!sideBySideItem(
item: a!richTextDisplayField(
value: {
if(
or(
isnull(local!selectedEmployees),
length(local!selectedEmployees) = 0
),
a!richTextItem(text: "None", style: "EMPHASIS"),
{
a!richTextIcon(icon: "USER-CIRCLE", color: "ACCENT")
}
)
},
marginBelow: "LESS"
),
width: "MINIMIZE"
),
a!sideBySideItem(
item: a!richTextDisplayField(
value: {
if(
or(
isnull(local!selectedEmployees),
length(local!selectedEmployees) = 0
),
a!richTextItem(text: "None", style: "EMPHASIS"),
{ a!richTextItem(text: fv!item.[recordType!Employee.fields.firstName] & " " & fv!item.[recordType!Employee.fields.lastName] ) }
)
},
marginBelow: "LESS"
)
),
a!sideBySideItem(
item: a!richTextDisplayField(
value: {
if(
or(
isnull(local!selectedEmployees),
length(local!selectedEmployees) = 0
),
a!richTextItem(text: "None", style: "EMPHASIS"),
{
a!richTextIcon(
icon: "times",
link: a!dynamicLink(
value: fv!index,
saveInto: {
a!save(
local!selection,
remove(local!selection, fv!index)
),
a!save(
local!selectedEmployees,
remove(local!selectedEmployees, fv!index)
)
}
),
linkStyle: "STANDALONE",
color: "SECONDARY"
),
char(10)
}
)
},
marginBelow: "LESS"
),
width: "MINIMIZE"
)
}
)
},
marginBelow: "EVEN_LESS"
)
)
}
),
}
)
}
)
}
)
| Solve the following leet code problem |
Make a Component Required Based on a User Selection
Make a paragraph component conditionally required based on the user selection.
This scenario demonstrates:
How to configure a required parameter of one component based off the interaction of another
| a!localVariables(
local!isCritical,
local!phoneNumber,
a!formLayout(
label: "Example: Conditionally Required Field",
contents:{
a!columnsLayout(
columns:{
a!columnLayout(
contents:{
a!checkboxField(
label: "Is Mission Critical",
choiceLabels: "Check the box if the employee will be on a mission critical team",
choiceValues: {true},
value: local!isCritical,
saveInto: local!isCritical
)
}
),
a!columnLayout(
contents:{
a!textField(
label: "Cell Number",
placeholder:"555-456-7890",
required: local!isCritical,
value: local!phoneNumber,
saveInto: local!phoneNumber,
validations: if( len(local!phoneNumber) > 12, "Contains more than 12 characters. Please reenter phone number, and include only numbers and dashes", null )
)
}
)
}
)
},
buttons:a!buttonLayout(
primaryButtons:{
a!buttonWidget(
label:"Submit",
submit: true
)
}
)
)
)
| Solve the following leet code problem |
Offline Mobile Task Report
Display a task report for a user that will work in Appian Mobile, even when the user is offline.
| You can create offline mobile tasks that users can access on Appian Mobile even if they don't have an internet connection.
To display these tasks in a task report, you'll need to follow the Design Best Practices for Offline Mobile.
Specifically, you will need to:
Load the data you need at the top of the interface.
Get the value for partially supported functions at the top of the interface, like the process task link component and user() function.
You will do this by creating local variables at the top of the interface expression. When a user refreshes their tasks while they are online, the local variables will be evaluated and their data will be cached on the device. That way, the data will be available even if the user is offline. For more information about how offline mobile works with data, see How Offline Mobile Works.
See alsoCopy link to clipboard
For more information about creating and configuring task reports, see:
Task Report Tutorial
Configuring Process Reports
Process Report Object
Process and Process Report Data
For the drag-and-drop pattern that can be used in non-offline mobile interfaces, see the Task Report Pattern.
Create a task report and constantCopy link to clipboard
For this recipe, you'll need to create a task report and a constant to reference the task report.
For simplicity, we'll duplicate the Active Tasks prebuilt system report. But if you'd like, you can use one of the other prebuilt system task reports, or create and edit a custom process report.
To create a new task report and constant:
In the Build view of your application, click NEW > Process Report.
Select Duplicate existing process report.
For Process Report to Duplicate, select active_tasks.
Enter a Name for the report.
For Save In, select a folder to save the report in.
Click CREATE.
Create a constant of type Document and select the process report for the Value.
Create an interface and enable it for offline mobileCopy link to clipboard
Create an interface.
Select EXPRESSION mode.
Copy and paste the interface expression into the Interface Definition.
Replace the cons!MY_ACTIVE_TASKS constant with the constant you created.
Click the settings icon > Properties.
Select Make Available Offline and click OK.
Interface expressionCopy link to clipboard
This expression is based off of the task report pattern, but it doesn't use a!forEach() to dynamically create the grid rows. Use this pattern if you know which columns your task report has and want the expression to be a bit more straightforward. You may need to update the columns with the columns from your task report.
See Configuring Process Reports for more information displaying task report data in an interface.
SAIL Code :
a!localVariables(
/* The task data returned by a process analytics query */
local!taskReportData: a!queryProcessAnalytics(
/* Replace this constant with a Document constant that uses a task report for the value */
report: cons!MY_ACTIVE_TASKS,
query: a!query(
pagingInfo: a!pagingInfo(
startIndex: 1,
batchSize: -1,
sort: a!sortInfo(field: "c2")
)
)
),
/* a!processTaskLink() is partially compatible with offline mobile so
we call it in a local variable at the top of the interface */
local!processTaskLinks: a!forEach(
items: local!taskReportData,
/* In order to save the process task link for each row, we use update() to update the data
returned from local!taskReportData. For each row of data, we insert a new field
called "link" with the value of a!processTaskLink() for that row */
expression: a!update(
data: fv!item,
index: "link",
value: a!processTaskLink(
label: fv!item.c0,
task: fv!item.dp0
)
)
),
/* Because we also want to use the user() and group() functions to display the assignees,
we use update() to update the data returned from local!processTaskLinks. For each row of data we
insert a new field called "assigned" with the value of user() or group() for each row. */
local!updateOfflineData: a!forEach(
items: local!processTaskLinks,
expression: a!update(
data: fv!item,
index: "assigned",
/* Because tasks can be assigned to multiple users or groups,
we use a!forEach() to evaluate the if() logic for each user or group */
value: a!forEach(
items: fv!item.c8,
expression: if(
/* Check if User (which returns 4 for the runtime type number), otherwise its a Group */
runtimetypeof(fv!item) = 4,
if(a!isNotNullOrEmpty(fv!item), user(fv!item, "firstName") & " " & user(fv!item, "lastName"), ""),
if(a!isNotNullOrEmpty(fv!item), group(fv!item, "groupName"), "")
)
)
)
),
{
a!sectionLayout(
label: "Employee Tasks",
labelColor: "SECONDARY",
contents: {
a!gridField(
labelPosition: "COLLAPSED",
/* For the grid data, we use local!updateOfflineData,
which contains the new "link" and "assigned" fields */
data: local!updateOfflineData,
columns: {
a!gridColumn(
label: "Name",
value: a!linkField(
/* We reference the value for a!processTaskLink() using the new field name, "link" */
links: fv!row.link
)
),
a!gridColumn(
label: "Process",
value: fv!row.c3
),
a!gridColumn(
label: "Status",
value: a!match(
value: fv!row.c5,
equals: 0,
then: a!richTextDisplayField(
value: {a!richTextIcon(icon: "user-o", color: "#666666")," Assigned"}
),
equals: 1,
then: a!richTextDisplayField(
value: {a!richTextIcon(icon: "user-check", color: "ACCENT")," Accepted"}
),
default: fv!value
)
),
a!gridColumn(
label: "Assigned To",
/* We reference the user and group names using the new field name, "assigned" */
value: fv!row.assigned
),
a!gridColumn(
label: "Assigned On",
value: fv!row.c2
)
},
pageSize: 10,
borderStyle: "LIGHT",
rowHeader: 1
)
}
)
}
)
Display the task report on a site page.
To display the task report on a site page, you will need to configure it as an action. To do this, you will create a process model and add it as an action type page in a site.
To configure a process model to use the interface as a start form:
Create a process model.
Right-click the Start Node and select Process Start Form.
For Interface select the interface you created and click OK.
Click File > Save & Publish.
To create a site that displays the task report:
Create a site.
Click ADD PAGE and give the page a Title.
For Type, select Action.
For Content, select the process model you created and click ADD.
Click SAVE CHANGES.
Test the task report in Appian Mobile
Offline mobile interfaces evaluate differently in Appian Mobile than they do in a browser. In a browser, they evaluate like any other interface. In Appian Mobile, they sync with the server when the interface loads, then store that data on the device so that the user can access it whether they are online or offline.
In order to verify the offline-enabled task report works correctly on Appian Mobile, you need to test it in the Appian Mobile app.
To test the task report in Appian Mobile:
On a mobile device, open the Appian Mobile app.
Navigate to the site you created and select the page with the task report.
Select a task and use the paging in the grid. Verify that there are no errors.
Note: After syncing a custom task list, Appian recommends waiting approximately 5 minutes before opening an offline task to ensure all tasks have time to download to the device. If a user opens a task before the download completes, there is a chance that some of the data they enter into the form could be lost. The strength of their internet connection, volume of data, and memory capacity on the device will affect how quickly the tasks are downloaded to the device.
| Solve the following leet code problem |
Percentage of Online Sales
This pattern illustrates how to calculate the percent of sales generated from online orders and display it in a gauge component. This pattern also provides a sample scenario to show how you can take common business requirements and quickly turn them into a report.
You'll notice that this pattern provides more than just an expression, it shows you the fastest way to build reports in Design Mode. To get the most out of this pattern, follow the steps in Create this pattern to learn how to build advanced reports using the latest low-code features
| ScenarioCopy link to clipboard
Account managers at the Appian Retail company want to know how much of their 2021 sales were generated from online sales so they can determine if they need to do more online advertising, or hire more in-person staff.
To show the percentage of online sales, you’ll use the pattern on this page to create a query using a!queryRecordType() to calculate the sum of sales for all orders purchased in 2021 and the sum of sales for orders purchased online in 2021. Then, you'll uses a gauge component to calculate and display the percentage of online sales generated in 2021.
To allow account managers to better understand whether online sales are growing, stagnant, or decreasing, you'll also create a second gauge component that shows the percentage of online sales generated in 2020.
SetupCopy link to clipboard
This pattern uses data from the Appian Retail application, available for free in Appian Community Edition. To follow along with this pattern, log in to Appian Community to request the latest Appian Community Edition site.
If you do not see the Appian Retail application available in your existing Appian Community Edition, you can request a new Appian Community Edition to get the latest application contents available.
This pattern will use data from the following record types in the Appian Retail application:
Order record type: Contains order information like the order number, date, status, and whether it was purchased online or in stores. For example, order number SO43659 was purchased in stores on 5/31/2019 and the order is closed.
Order Detail record type: Contains specific order details like the number of order items, order totals, promo codes applied, and products. For example, the order above contained one product that cost $2,024.99.
Create this patternCopy link to clipboard
To create this pattern, you will:
Get the sum of total sales and the sum of online sales for orders purchased in 2021.
Show the percentage of online sales in 2021.
Get the sum of total sales and the sum of online sales for orders purchased in 2020.
Show the percentage of online sales in 2020.
Step 1: Get the sum of total sales and the sum of online sales for orders purchased in 2021Copy link to clipboard
Your first step is to get the sum of sales for all orders purchased in 2021, and the sum of sales for orders purchased online this year. To calculate these values, you'll create a query using a!queryRecordType() and save the value in a local variable within an interface.
In the query, you'll filter the data so you only return orders from 2021. Then, you'll group by the year when the order was made, and calculate two measures: the sum of all orders, and the sum of orders that have the onlineOrderFlag equal to 1, where 1 means the order was made online, and 0 means the order was made in-stores.
We'll use this query in the next step to calculate the percentage in the gauge component.
To calculate these values:
In the Appian Retail application, go to the Build view.
Click NEW > Interface.
Configure the interface properties and click CREATE.
Click EXPRESSION in the title bar.
Copy and paste the following expression. This creates a local variable with our query, and includes a column layout that we'll use later in this pattern:
Note: These record type references are specific to the Appian Retail application. If you're following along in the Appian Retail application, you can copy and paste this expression without updating the record type references.
SAIL CODE:
a!localVariables(
local!onlineSales2021: a!queryRecordType(
recordType: 'recordType!{ad898682-e651-4b2d-af67-47c1fcb1171f}Order',
/* Only include orders created in 2021 */
filters: {
a!queryFilter(
field: 'recordType!{ad898682-e651-4b2d-af67-47c1fcb1171f}Order.fields.{fbcc99f6-1ddf-4923-903b-18122a1737c6}orderDate',
operator: "BETWEEN",
value: {
todatetime("01/01/2021"),
todatetime("12/31/2021")
}
)
},
fields: {
a!aggregationFields(
/* Group by the order date year */
groupings: a!grouping(
field: 'recordType!{ad898682-e651-4b2d-af67-47c1fcb1171f}Order.fields.{fbcc99f6-1ddf-4923-903b-18122a1737c6}orderDate',
interval: "YEAR",
alias: "orderDateYear"
),
measures: {
/* Get the sum of all orders */
a!measure(
field: 'recordType!{ad898682-e651-4b2d-af67-47c1fcb1171f}Order.relationships.{0bde4028-fd7a-411f-97ad-7ad5b84e0d18}orderDetail.fields.{db456082-5f77-4765-bc3e-f662651e0d52}lineTotal',
function: "SUM",
alias: "totalSales"
),
/* Get the sum of all orders that have an online order flag */
a!measure(
field: 'recordType!{ad898682-e651-4b2d-af67-47c1fcb1171f}Order.relationships.{0bde4028-fd7a-411f-97ad-7ad5b84e0d18}orderDetail.fields.{db456082-5f77-4765-bc3e-f662651e0d52}lineTotal',
function: "SUM",
alias: "onlineSales",
filters: {
a!queryFilter(
field: 'recordType!{bec4a875-9980-4bbf-a38c-c492ebed065a}Order Detail.relationships.{e6b1dbca-6c3c-4540-a093-3c581a73ad17}order.fields.{5bade7d5-5fbc-4cc4-807f-907f8f65969b}onlineOrderFlag',
operator: "=",
value: 1
),
}
)
}
)
},
pagingInfo: a!pagingInfo(1, 10)
).data,
/* Column layout that we'll use for our gauge components */
{
a!columnsLayout(
columns: {
a!columnLayout(contents: {}),
a!columnLayout(contents: {})
}
)
}
)
Step 2: Show the percentage of online sales in 2021Copy link to clipboard
Now that you have a query that calculates your total sales in 2021 and your sales from online orders that year, you can calculate the percentage of online sales directly in a gauge component.
To calculate and display the percentage of online sales in 2021:
In your interface, click DESIGN in the title bar. A column layout with two columns appears.
From the PALETTE, drag a GAUGE component into the left column layout.
In the Gauge component configuration, hover over Fill Percentage and click Edit as Expression.
In the Fill Percentage dialog, replace the existing value with the following expression. This will calculate the percent of online sales:
SAIL code :
local!onlineSales2021.onlineSales / local!onlineSales2021.totalSales * 100
Click OK.
In Secondary Text, enter 2021.
Hover over Tooltip and click Edit as Expression .
In the Tooltip dialog, enter the following expression. This will display the sum of sales for this year.
SAIL Code :
"Online Sales: " & a!currency(
isoCode: "USD",
value: a!defaultValue(local!onlineSales2021.onlineSales,0)
)
Click OK.
Step 3: Get the sum of total sales and the sum of online sales for orders purchased in 2020Copy link to clipboard
Now you need to calculate the percentage of online sales in 2020.
To get this percentage, you first need to gets the sum of sales for all orders purchased in 2020, as well as the sum of sales for orders purchased online that year.
To calculate these values:
In your interface, click EXPRESSION in the title bar.
In the Interface Definition, enter a new line after line 48.
Copy and paste the following expression on line 49. This creates a second local variable with our second query:
SAIL Code:
local!onlineSales2020: a!queryRecordType(
recordType: 'recordType!{ad898682-e651-4b2d-af67-47c1fcb1171f}Order',
/* Only include orders created in 2020 */
filters: {
a!queryFilter(
field:'recordType!{ad898682-e651-4b2d-af67-47c1fcb1171f}Order.fields.{fbcc99f6-1ddf-4923-903b-18122a1737c6}orderDate',
operator: "BETWEEN",
value: {
todatetime("01/01/2020"),
todatetime("12/31/2020")
}
)
},
fields: {
a!aggregationFields(
/* Group by the order date year */
groupings: a!grouping(
field: 'recordType!{ad898682-e651-4b2d-af67-47c1fcb1171f}Order.fields.{fbcc99f6-1ddf-4923-903b-18122a1737c6}orderDate',
interval: "YEAR",
alias: "orderDateYear"
),
measures: {
/* Get the sum of all orders */
a!measure(
field: 'recordType!{ad898682-e651-4b2d-af67-47c1fcb1171f}Order.relationships.{0bde4028-fd7a-411f-97ad-7ad5b84e0d18}salesOrderDetail.fields.{db456082-5f77-4765-bc3e-f662651e0d52}lineTotal',
function: "SUM",
alias: "totalSales2020"
),
/* Get the sum of all orders that have an online order flag */
a!measure(
field: 'recordType!{ad898682-e651-4b2d-af67-47c1fcb1171f}Order.relationships.{0bde4028-fd7a-411f-97ad-7ad5b84e0d18}salesOrderDetail.fields.{db456082-5f77-4765-bc3e-f662651e0d52}lineTotal',
function: "SUM",
alias: "onlineSales2020",
filters: {
a!queryFilter(
field: 'recordType!{bec4a875-9980-4bbf-a38c-c492ebed065a}Order Detail.relationships.{e6b1dbca-6c3c-4540-a093-3c581a73ad17}salesOrderHeader.fields.{5bade7d5-5fbc-4cc4-807f-907f8f65969b}onlineOrderFlag',
operator: "=",
value: 1
),
}
)
}
)
},
pagingInfo: a!pagingInfo(1,10)
).data,
Step 4: Show the percentage of online sales last yearCopy link to clipboard
Now that you have your query, you'll add a second gauge component to calculate and display the online sales percentage for 2020.
To calculate and display the percentage of online sales in 2020:
In your interface, click DESIGN in the title bar.
From the PALETTE, drag a GAUGE component into the right column layout.
In the Gauge component configuration, hover over Fill Percentage and click Edit as Expression .
In the Fill Percentage dialog, replace the existing value with the following expression:
SAIL Code:
local!onlineSales2020.onlineSales2020 / local!onlineSales2020.totalSales2020 * 100
Click OK.
In Secondary Text, enter 2020.
Hover over Tooltip and click Edit as Expression .
In the Tooltip dialog, enter the following expression:
SAIL Code Expression :
"Online Sales: " & a!currency(
isoCode: "USD",
value: a!defaultValue(local!onlineSales2020.onlineSales2020,0)
)
Click OK.
From the PALETTE, drag a RICH TEXT component above the columns layout and configure the following:
In Display Value, keep the default selection of Use editor.
In the editor, enter Percent of Online Sales.
In the editor, highlight the text, then click Size Size icon and select Medium Header.
Click SAVE CHANGES.
Full SAIL Code expression :
a!localVariables(
local!onlineSales2021: a!queryRecordType(
recordType: 'recordType!{ad898682-e651-4b2d-af67-47c1fcb1171f}Order',
/* Only include orders created in 2021 */
filters: {
a!queryFilter(
field: 'recordType!{ad898682-e651-4b2d-af67-47c1fcb1171f}Order.fields.{fbcc99f6-1ddf-4923-903b-18122a1737c6}orderDate',
operator: "BETWEEN",
value: {
todatetime("01/01/2021"),
todatetime("12/31/2021")
}
)
},
fields: {
a!aggregationFields(
/* Group by the order date year */
groupings: a!grouping(
field: 'recordType!{ad898682-e651-4b2d-af67-47c1fcb1171f}Order.fields.{fbcc99f6-1ddf-4923-903b-18122a1737c6}orderDate',
interval: "YEAR",
alias: "orderDateYear"
),
measures: {
/* Get the sum of all orders */
a!measure(
field: 'recordType!{ad898682-e651-4b2d-af67-47c1fcb1171f}Order.relationships.{0bde4028-fd7a-411f-97ad-7ad5b84e0d18}orderDetail.fields.{db456082-5f77-4765-bc3e-f662651e0d52}lineTotal',
function: "SUM",
alias: "totalSales"
),
/* Get the sum of all orders that have an online order flag */
a!measure(
field: 'recordType!{ad898682-e651-4b2d-af67-47c1fcb1171f}Order.relationships.{0bde4028-fd7a-411f-97ad-7ad5b84e0d18}orderDetail.fields.{db456082-5f77-4765-bc3e-f662651e0d52}lineTotal',
function: "SUM",
alias: "onlineSales",
filters: {
a!queryFilter(
field: 'recordType!{bec4a875-9980-4bbf-a38c-c492ebed065a}Order Detail.relationships.{e6b1dbca-6c3c-4540-a093-3c581a73ad17}order.fields.{5bade7d5-5fbc-4cc4-807f-907f8f65969b}onlineOrderFlag',
operator: "=",
value: 1
),
}
)
}
)
},
pagingInfo: a!pagingInfo(1, 10)
).data,
local!onlineSales2020: a!queryRecordType(
recordType: 'recordType!{ad898682-e651-4b2d-af67-47c1fcb1171f}Order',
/* Only include orders created in 2020 */
filters: {
a!queryFilter(
field: 'recordType!{ad898682-e651-4b2d-af67-47c1fcb1171f}Order.fields.{fbcc99f6-1ddf-4923-903b-18122a1737c6}orderDate',
operator: "BETWEEN",
value: {
todatetime("01/01/2020"),
todatetime("12/31/2020")
}
)
},
fields: {
a!aggregationFields(
/* Group by the order date year */
groupings: a!grouping(
field: 'recordType!{ad898682-e651-4b2d-af67-47c1fcb1171f}Order.fields.{fbcc99f6-1ddf-4923-903b-18122a1737c6}orderDate',
interval: "YEAR",
alias: "orderDateYear"
),
measures: {
/* Get the sum of all orders */
a!measure(
field: 'recordType!{ad898682-e651-4b2d-af67-47c1fcb1171f}Order.relationships.{0bde4028-fd7a-411f-97ad-7ad5b84e0d18}orderDetail.fields.{db456082-5f77-4765-bc3e-f662651e0d52}lineTotal',
function: "SUM",
alias: "totalSales2020"
),
/* Get the sum of all orders that have an online order flag */
a!measure(
field: 'recordType!{ad898682-e651-4b2d-af67-47c1fcb1171f}Order.relationships.{0bde4028-fd7a-411f-97ad-7ad5b84e0d18}orderDetail.fields.{db456082-5f77-4765-bc3e-f662651e0d52}lineTotal',
function: "SUM",
alias: "onlineSales2020",
filters: {
a!queryFilter(
field: 'recordType!{bec4a875-9980-4bbf-a38c-c492ebed065a}Order Detail.relationships.{e6b1dbca-6c3c-4540-a093-3c581a73ad17}order.fields.{5bade7d5-5fbc-4cc4-807f-907f8f65969b}onlineOrderFlag',
operator: "=",
value: 1
),
}
)
}
)
},
pagingInfo: a!pagingInfo(1, 10)
).data,
/* Column layout that we'll use for our gauge components */
{
a!richTextDisplayField(
labelPosition: "COLLAPSED",
value: {
a!richTextHeader(text: { "Percent of Online Sales" })
}
),
a!columnsLayout(
columns: {
a!columnLayout(
contents: {
a!gaugeField(
labelPosition: "COLLAPSED",
percentage: local!onlineSales2021.onlineSales / local!onlineSales2021.totalSales * 100,
primaryText: a!gaugePercentage(),
secondaryText: "2021",
tooltip: "Online Sales: " & a!currency(
isoCode: "USD",
value: a!defaultValue(local!onlineSales2021.onlineSales, 0)
)
)
}
),
a!columnLayout(
contents: {
a!gaugeField(
labelPosition: "COLLAPSED",
percentage: local!onlineSales2020.onlineSales2020 / local!onlineSales2020.totalSales2020 * 100,
primaryText: a!gaugePercentage(),
secondaryText: "2020",
tooltip: "Online Sales: " & a!currency(
isoCode: "USD",
value: a!defaultValue(
local!onlineSales2020.onlineSales2020,
0
)
)
)
}
)
}
)
}
)
| Solve the following leet code problem |
End of preview. Expand
in Dataset Viewer.
No dataset card yet
New: Create and edit this dataset card directly on the website!
Contribute a Dataset Card- Downloads last month
- 2