This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

VBScript: The same code works in one of two different libraries and does not work in the other.

The same code works in one of two different libraries and does not work in the other. In the vbscript code written for the object to be created automatically, all the property values ​​of the object come as desired in one of the library. It does not return property values ​​for the same code in another library as desired. The employeeNameSurname property value to be copied from another object can be taken as a value for one library, but not for another library.

The codes are as follows.

Dim ObjClass: ObjClass = Vault.ObjectOperations.GetObjectInfo(ObjVer,true).Class
Const objType =211

if ObjClass = 102 then
AutoEducation
end if
Public Function AutoEducation
Dim typeOfEducation: typeOfEducation = 1311
Dim formOfEducation: formOfEducation = 1112
Dim educationOption: educationOption = 2113
Dim educationSubject: educationSubject = 1068
Dim educationTime: educationTime = 1067
Dim educationStartDate: educationStartDate = 1065
Dim educationStartTime: educationStartTime = 1127
Dim educationEndDate: educationEndDate = 1066
Dim educationEndTime: educationEndTime = 1128
Dim educationOfficer: educationOfficer = 2049
Dim allDay: allDay = 1463
Dim educationBudget: educationBudget = 2060
Dim educationContent: educationContent = 1461
Dim educationLocation: educationLocation = 2053

Dim objEducation: objEducation = 106
Dim clsEducation: clsEducation = 8
Dim propVals: Set propVals = CreateObject("MFilesAPI.PropertyValues")
Dim onePropVal: Set onePropVal = CreateObject("MFilesAPI.PropertyValue")

Dim arrayListEducationSubject: Set arrayListEducationSubject = CreateObject( "System.Collections.ArrayList" )
arrayListEducationSubject.Add 1
arrayListEducationSubject.Add 3
arrayListEducationSubject.Add 12

onePropVal.PropertyDef = 100
onePropVal.TypedValue.SetValue MFDatatypeLookup, clsEducation
propVals.Add -1, onePropVal

onePropVal.PropertyDef = typeOfEducation
onePropVal.TypedValue.SetValue MFDatatypeLookup, 1
propVals.Add -1, onePropVal

onePropVal.PropertyDef = formOfEducation
onePropVal.TypedValue.SetValue MFDatatypeLookup, 1
propVals.Add -1, onePropVal

onePropVal.PropertyDef = educationSubject
onePropVal.TypedValue.SetValue MFDatatypeMultiSelectLookup, arrayListEducationSubject.ToArray()
propVals.Add -1, onePropVal

onePropVal.PropertyDef = educationContent
onePropVal.TypedValue.SetValue MFDatatypeMultiLineText, "Oryantasyon Eğitimi"
propVals.Add -1, onePropVal

onePropVal.PropertyDef = educationOption
onePropVal.TypedValue.SetValue MFDatatypeLookup, 1
propVals.Add -1, onePropVal

onePropVal.PropertyDef = educationLocation
onePropVal.TypedValue.SetValue MFDatatypeLookup, 2
propVals.Add -1, onePropVal

onePropVal.PropertyDef = allDay
onePropVal.TypedValue.SetValue MFDatatypeLookup, 1
propVals.Add -1, onePropVal

'onePropVal.PropertyDef = educationTime
'onePropVal.TypedValue.SetValue MFDatatypeText, ""
'propVals.Add -1, onePropVal

onePropVal.PropertyDef = educationStartDate
onePropVal.TypedValue.SetValue MFDatatypeDate, DateAdd("d",0,Now())
propVals.Add -1, onePropVal

onePropVal.PropertyDef = educationEndDate
onePropVal.TypedValue.SetValue MFDatatypeDate, DateAdd("d",0,Now())
propVals.Add -1, onePropVal

onePropVal.PropertyDef = educationStartTime
onePropVal.TypedValue.SetValue MFDatatypeTime, "08:30"
propVals.Add -1, onePropVal

onePropVal.PropertyDef = educationEndTime
onePropVal.TypedValue.SetValue MFDatatypeTime, "18:30"
propVals.Add -1, onePropVal

onePropVal.PropertyDef = educationBudget
onePropVal.TypedValue.SetValue MFDatatypeInteger, 0
propVals.Add -1, onePropVal

Dim employeeNameSurname : employeeNameSurname = PropertyValues.SearchForProperty(0).TypedValue.Value
onePropVal.PropertyDef = educationParticipant
onePropVal.TypedValue.SetValue MFDatatypeText, employeeNameSurname
propVals.Add -1, onePropVal

onePropVal.PropertyDef = 22
onePropVal.TypedValue.SetValue MFDataType.MFDatatypeBoolean, false
propVals.Add -1, onePropVal

Dim objectVersionAndProperties: set objectVersionAndProperties = Vault.ObjectOperations.CreateNewObject(objEducation, propVals , nothing, nothing)
Call Vault.ObjectOperations.CheckIn(objectVersionAndProperties.ObjVer)

End Function

Many Thanks.

Parents
  • Is there an error?

    What's the difference between the vaults?  I assume, at a minimum, the property and value list item IDs are different, so have you altered those?

  • Actually, there is no difference between the boxes. It may just be the version difference. Also, the feature definitions are the same. The definitions for the property value that I can't get the value for are the same in both libraries. There is a case of working in one library and not working in the other in the code of searching from the list (MFDatatypeLookup). As a feature definition for this case, one has a multi-select feature, while the other does not have a multi-select feature.









    Please help me.
Reply
  • Actually, there is no difference between the boxes. It may just be the version difference. Also, the feature definitions are the same. The definitions for the property value that I can't get the value for are the same in both libraries. There is a case of working in one library and not working in the other in the code of searching from the list (MFDatatypeLookup). As a feature definition for this case, one has a multi-select feature, while the other does not have a multi-select feature.









    Please help me.
Children
  • I'm not sure what exactly is happening here.  You say that it does not work, but what does that mean?  What exactly happens?  Is there an error?

    I notice that you don't declare "educationParticipant", could that be the issue?  Could that be defaulting to something (zero?) which works in one vault but not another (possibly due to a vault structural difference)?  You might want to add "Option Explicit" to the top of your VBScript to ensure that you don't get issues with undeclared variables.

    If you work for a partner then you may want to reach out to your partner manager for more support.  If you work for an end-user then your partner may be able to provide you with some assistance to see what's going on.

  • First of all, thank you so much for replying so quickly. I solved the problem of not bringing the value of the participant feature by fixing the deficiency you mentioned. 

  • I have one more question about this code. I'm trying to set value in list-enabled property definitions in my code. But my code is not working. The codes that don't work are as follows:

    onePropVal.PropertyDef = educationOption
    onePropVal.TypedValue.SetValue MFDatatypeLookup, 1
    propVals.Add -1, onePropVal

    onePropVal.PropertyDef = educationLocation
    onePropVal.TypedValue.SetValue MFDatatypeLookup, 3
    propVals.Add -1, onePropVal

    onePropVal.PropertyDef = allDay
    onePropVal.TypedValue.SetValue MFDatatypeLookup, 1
    propVals.Add -1, onePropVal

    Although I change the number in the code, the value selected in the property does not change. It always comes the same value in the list.

  • I'm not sure, but try re-creating "onePropVal" for each one.  I have seen some situations where re-using the same variable like that causes odd issues.

  • The situation you mentioned was valid for allDay and educationOption value list features. However, this was not the case for the educationLocation feature. There are more than 2 values ​​in the value list of the EducationLocation property. Maybe it has something to do with it. Can something be done using MFilesAPI.SearchConditions instead of using MFDatatypeLookup?