AffectItem(item, hint = ”) : Item
Alias: MarkAffected
Marks an item as affected (modified).
Affected items are included in remote notification for subscribed clients to be notified in real time.
AffectItem Parameters
item : Item
hint : String? = ”
Hint how to refresh (null to unmark).
Can be for example a view name for client to know what to refresh.
AffectItem Examples
AffectItem($Item);
AffectItem($Item, 'Address');
ChangeItemType(item, newItemType, properties?, skipEvent = false) : Item
Changes type of an item.
ChangeItemType Parameters
item : Item
newItemType : ItemType
Can be full name of the ItemType.
Usually new type is from the same polymorphic hierarchy (base type and polymorphic descendandts).
properties? : Dict?
To replace existing properties with new values during type change, or to add missing values.
skipEvent : Boolean = false
True to skip runtime events (OnCreate, OnChange).
ChangeItemType Examples
$Item.ChangeItemType($.TargetSolution.TargetType);
CreateItem(itemType, properties?, skipEvent = false) : Item
Creates a new item.
CreateItem Parameters
itemType : ItemType
Can be full name of the ItemType.
properties? : Dict?
Initial values for item properties.
skipEvent : Boolean = false
True to skip OnCreate runtime event (and other events too if any).
CreateItem Examples
var item = $.TargetSolution.TargetType.CreateItem({ Name = 'New item' });
DeleteItem(item, skipEvent = false) : Boolean
Alias: Delete
Deletes an item.
Returns false if item is null or already deleted.
DeleteItem Parameters
item : Item?
Item to delete.
skipEvent : Boolean = false
True to skip OnDelete runtime event (and other events if any).
DeleteItem Examples
var ok = DeleteItem($Item);
DocumentFiles(solution?, itemId?) : Document[]
Returns document files in file storage.
DocumentFiles Parameters
solution? : Solution?
Can be Solution or solution ID to get files from solution.
itemId? : Guid?
Item ID to get only item document files.
DocumentFiles Examples
var documents = DocumentFiles($Item.$Solution, $Item.Id);
Export(solution, items?, config?) : Dict?
Exports items.
Export Parameters
solution : Solution
Main solution – can also be ItemType to export ItemType only (no zip).
items? : Item[]
Array of items.
config? : Dict?
{ ExcludeProperties = string[] }
FindItem(itemType, searchQuery?, includeArchived = false, excludeDerived = false) : Item?
Finds items by specified criteria and returns the first one.
FindItem Parameters
itemType : ItemType
Can be full name of the ItemType.
searchQuery? : ?
String to search by Name, or predicate function (e.g. x => x.Index > 1).
includeArchived : Boolean = false
True to include archived items (items in archive states).
excludeDerived : Boolean = false
True to not include derived types for abstract types and for types with IncludeDerived set to true.
FindItem Examples
var item = $.TargetSolution.TargetType.FindItem(i => i.Name == 'Some item');
var item = $.TargetSolution.TargetType.FindItem('Some item');
FindItems(itemType, searchQuery?, sortBy?, start = 0, count = -1, includeArchived = false, excludeDerived = false) : Item[]
Finds items by specified criteria.
FindItems Parameters
itemType : ItemType
Can be full name of the ItemType or array of types.
searchQuery? : ?
String to search by Name, or predicate function (e.g. x => x.Index > 1).
sortBy? : String?
Comma separated property names to sort by.
If a property name starts with ‘!’ then descending order is used.
start : Integer = 0
Positive number for skip first number of items from the result.
count : Integer = -1
Non-negative number to limit the number of items in the result.
includeArchived : Boolean = false
True to include archived items (items in archive states).
excludeDerived : Boolean = false
True to not include derived types for abstract types and for types with IncludeDerived set to true.
FindItems Examples
var items = $.TargetSolution.TargetType.FindItems(); // all items
var items = $.TargetSolution.TargetType.FindItems(i => i.CreatedBy == $User);
var items = $.TargetSolution.TargetType.FindItems(i => i.CreatedBy == $User, 'Name,!Sequence');
FindOrCreateItem(itemType, searchQuery?, properties?, skipEvent = false) : Item
Finds the first item by specified criteria, otherwise creates a new item.
FindOrCreateItem Parameters
itemType : ItemType
Can be full name of the ItemType.
searchQuery? : ?
String to search by Name, or predicate function (e.g. x => x.Index > 1).
properties? : Dict?
Initial values for the new item (if no existing item is found).
skipEvent : Boolean = false
True to skip OnCreate runtime event (and other events too if any).
FindOrCreateItem Examples
var item = $.TargetSolution.TargetType.FindOrCreateItem(i => i.Name == 'Some item', { Name = 'Some item' });
GetItemType(fullName, required = true) : ItemType?
Returns an item type by its full name.
GetItemType Parameters
fullName : String
Can be Solution.ItemType or Solution.
required : Boolean = true
False to return null if item type was not found.
GetItemType Examples
var itemType = GetItemType('Solution.ItemType');
History(item, filter?) : Dict[]
Returns history log of item changes.
History Parameters
item : Item?
filter? : ?
String to search by Name, or predicate function (e.g. x => x.Index > 1).
History Examples
var records = $Item.History();
var records = $Item.History(i => i.Name.Contains('text'));
Item(itemId) : Item?
Returns an item by its ID.
Does not check if the item exists, so errors may occur later on item properties access.
Item Parameters
itemId : String?
Can be Guid, Guid.ComplexProperty, Guid.ArrayProperty.ItemID or Guid.ArrayProperty.ItemID.ComplexProperty
Item Examples
var item = Item('db72e5cd-9efe-4ad1-a5f8-a65ac480c00e');
LockItem(item, numberOfAttempts = 50) : Item
Alias: Lock
Locks an item till the end of the current transaction so concurrent attempts to modify the item in other transactions will wait (and fail after timeout).
LockItem Parameters
item : Item
numberOfAttempts : Integer = 50
Number of attempts to lock the item (in case of another transaction lock).
If zero, then the number of lock attempts is unlimited.
The delay between lock attempts is 100ms.
LockItem Examples
$Item.LockItem();
OrderItemTypes(itemTypes) : ItemType[]
Orders Item Types according to their dependencies to each other.
The first element in the resulting array is the least dependent type.
OrderItemTypes Parameters
itemTypes : ItemType[]
OrderItemTypes Examples
var ordered = OrderItemTypes($.TargetSolution.ItemTypes);
ParseSearch(search)
Parses items search query string.
ParseSearch Parameters
search : String
PromoteItem(item, state, args?, getResult = false) : Item
Alias: Promote
Promotes an item to another state.
PromoteItem Parameters
item : Item
state : String
Next state name.
args? : Dict?
Additional arguments for transition workflow.
getResult : Boolean = false
True to get explicit transition result instead of the item (or null, if there is no explicit result).
PromoteItem Examples
$Item.PromoteItem('NewState');
$Item.PromoteItem('NewState', { Param = true });
var wfResult = $Item.PromoteItem('NewState', missing, true);
ResolveReferences(array, name, itemType) : []
Resolves and loads all items for the given property for all items in the collection at once (eliminating N+1 problem).
ResolveReferences Parameters
array : Item[]
name : String
itemType : ItemType[]
Siblings(item, excludeSelf = false) : Item[]
Returns sibling items of an item (with the same parent if exists, or all the items of the same type otherwise).
Siblings Parameters
item : Item?
excludeSelf : Boolean = false
True to exclude the item itself from the result.
Siblings Examples
var siblingsWithItem = $Item.Siblings();
var siblingsWithoutItem = $Item.Siblings(true);
UpdateItem(item, properties, skipEvent = false) : Item
Alias: Update
Updates an item.
UpdateItem Parameters
item : Item
properties : Dict?
Properties to update.
skipEvent : Boolean = false
True to skip OnChange runtime event (and other events too if any).
UpdateItem Examples
$Item.UpdateItem({ Name = 'New name', SomeProp = true });