' Скрипт на кнопку?
' Проверяет заполненность свойства
' v 1.0.0
Option Explicit
Function DoEvent(UserSession, CardFrame, CardData, ActivateFlags, ModeID, FolderID)
Dim Prop2
Set Prop2 = Prop(CardData, "Свойство-2")
If GetProp(CardData, "Свойство-1", vbNullString) <> vbNullString Then
Prop2.Value("ReadOnly") = True
Prop2.Value("Required") = False
Else
Prop2.Value("ReadOnly") = False
Prop2.Value("Required") = True
End If
DoEvent = 2
End Function
' Получение секции карточки по имени
Function Sect(CardData, Alias)
Set Sect = CardData.Sections(CardData.Type.AllSections.GetByAlias(Alias).ID)
End Function
' Получение подчиненной секции по имени
Function SubSect(RowData, Alias)
Set SubSect = RowData.ChildSections(RowData.Section.Type.ChildSections.GetByAlias(Alias).ID)
End Function
' Нулевая строка секции MainInfo
Function MainInfo(CardData)
Set MainInfo = Sect(CardData, "MainInfo").FirstRow
End Function
' Строка свойства
Function Prop(CardData, Alias)
Set Prop = Nothing
Dim Row: For Each Row In Sect(CardData, "Properties").Rows
If Row.Value("Name") = Alias Then
Set Prop = Row
Exit Function
End If
Next
End Function
' Получение значения свойства
Function GetProp(CardData, Alias, DefaultValue)
Dim Row: Set Row = Prop(CardData, Alias)
If Row Is Nothing Then
GetProp = DefaultValue
Else
GetProp = Row.Value("Value")
If IsNull(GetProp) Then GetProp = DefaultValue
End If
End Function
' Установка значения свойства
Sub SetProp(CardData, Alias, Value, DisplayValue)
Prop(CardData, Alias).Value("Value") = Value
Prop(CardData, Alias).Value("DisplayValue") = DisplayValue
End Sub |