property value is not captured when call it in simple concatenating for other property

I have a scripted property (cDate) for extracting the last four digits from Date or timestamp built-in properties, such as taking "0124" from the date "17/01/2024." The script is functioning correctly in capturing the desired result. However, when I attempt to use this value in another property, it doesn't display as expected. The scripted value is obtaining the correct outcome, as demonstrated in this document:

but its not captured in (Ref No) property, unless i check out or create new version.

 also i reordered the properties so (Date, cDate) properties comes before ( Ref No).
i also checked the client configs to fill the properties automatically but still cant get it right.


cDate property script:

Option Explicit

Dim txtDate : txtDate = PropertyValues.SearchForProperty(1030).TypedValue.Value

Dim currentDate : currentDate = GetFormattedDate(txtDate)

If IsDate(txtDate) Then
Dim lastTwoDigitsYear : lastTwoDigitsYear = Right(currentDate(0), 2)

Output = currentDate(1) & lastTwoDigitsYear
Else
Output = "Invalid Date"
End If

Function GetFormattedDate(inputDate)
Dim parts : parts = Split(inputDate, "/")

If UBound(parts) = 2 Then
Dim yearPart, monthPart
yearPart = parts(2)
monthPart = Right("0" & parts(0), 2)

GetFormattedDate = Array(yearPart, monthPart)
Else
GetFormattedDate = Array("", "")
End If
End Function

Parents
  • Try using the BeforeCreateObjectFinalize event
    I haven't tested it with this script, but if not it's correct, I think you can get an idea of how to do it.

    remember to add the correct ids

    //////////////////////////////////////Script ////////////////////////////////

    dim classId : classId = PropertyValues.SearchForProperty(100).TypedValue.GetLookupID '

    if classId = 0 then ' class Id

    Dim oPropertyValues : Set oPropertyValues = CreateObject("MFilesAPI.PropertyValues")
    Dim txtDate : txtDate = PropertyValues.SearchForProperty(1030).TypedValue.Value
    Dim setDate : set setDate = PropertyValues.SearchForProperty(1031)' add cDate
    Dim refNo : set refNo = PropertyValues.SearchForProperty(1022) 'ref no

    Dim currentDate : currentDate = GetFormattedDate(txtDate)

    If IsDate(txtDate) Then

    Dim lastTwoDigitsYear : lastTwoDigitsYear = Right(currentDate(0), 2)
    setDate.Value.Value = currentDate(1) & lastTwoDigitsYear

    Dim values : values = Split(refNo.Value.DisplayValue, "-")
    refNo.Value.Value = values(0) + "-" + values(1) + "-" + values(2) + "-" + lastTwoDigitsYear + "-" + values(3)

    oPropertyValues.Add -1, setDate
    oPropertyValues.Add -1, refNo

    Vault.ObjectPropertyOperations.SetProperties ObjVer, oPropertyValues

    Else
    Err.Raise MFScriptCancel, "Invalid Date"
    End If
    End If

    Function GetFormattedDate(inputDate)
    Dim parts : parts = Split(inputDate, "/")

    If UBound(parts) = 2 Then
    Dim yearPart, monthPart
    yearPart = parts(2)
    monthPart = Right("0" & parts(0), 2)

    GetFormattedDate = Array(yearPart, monthPart)
    Else
    GetFormattedDate = Array("", "")
    End If
    End Function

Reply
  • Try using the BeforeCreateObjectFinalize event
    I haven't tested it with this script, but if not it's correct, I think you can get an idea of how to do it.

    remember to add the correct ids

    //////////////////////////////////////Script ////////////////////////////////

    dim classId : classId = PropertyValues.SearchForProperty(100).TypedValue.GetLookupID '

    if classId = 0 then ' class Id

    Dim oPropertyValues : Set oPropertyValues = CreateObject("MFilesAPI.PropertyValues")
    Dim txtDate : txtDate = PropertyValues.SearchForProperty(1030).TypedValue.Value
    Dim setDate : set setDate = PropertyValues.SearchForProperty(1031)' add cDate
    Dim refNo : set refNo = PropertyValues.SearchForProperty(1022) 'ref no

    Dim currentDate : currentDate = GetFormattedDate(txtDate)

    If IsDate(txtDate) Then

    Dim lastTwoDigitsYear : lastTwoDigitsYear = Right(currentDate(0), 2)
    setDate.Value.Value = currentDate(1) & lastTwoDigitsYear

    Dim values : values = Split(refNo.Value.DisplayValue, "-")
    refNo.Value.Value = values(0) + "-" + values(1) + "-" + values(2) + "-" + lastTwoDigitsYear + "-" + values(3)

    oPropertyValues.Add -1, setDate
    oPropertyValues.Add -1, refNo

    Vault.ObjectPropertyOperations.SetProperties ObjVer, oPropertyValues

    Else
    Err.Raise MFScriptCancel, "Invalid Date"
    End If
    End If

    Function GetFormattedDate(inputDate)
    Dim parts : parts = Split(inputDate, "/")

    If UBound(parts) = 2 Then
    Dim yearPart, monthPart
    yearPart = parts(2)
    monthPart = Right("0" & parts(0), 2)

    GetFormattedDate = Array(yearPart, monthPart)
    Else
    GetFormattedDate = Array("", "")
    End If
    End Function

Children
No Data