List of values with job charges

Good afternoon

I have a list of values with job types in the company, but some jobs are unique and some are not. I would like that when a worker is assigned a unique position, he does not allow another to be assigned the same position, but if he is assigned a position that is not unique, it does allow several workers to use the same position.

Any idea how I can limit some values like that?

I appreciate any help.

  • Hi, Johnny

    I would create a Job Positions object type. I would add a boolean uniqueness flag to it.

    In the Employee object I will add a position selection property that points to the Job Positions object type, in it I will use a validation script like the following

    'Create instance of current object properties
    Set oPropVals = CreateObject("MFilesApi.PropertyValues")
    Set oPropVals = Vault.ObjectPropertyOperations.GetProperties(ObjVer)
    
    'Get some ID's by alias
    iOTJobPosition = Vault.ObjectTypeOperations.GetObjectTypeIDByAlias("OT.JobPosition")
    iCLEmployee = Vault.ClassOperations.GetObjectClassIDbyAlias("CL.Employee")
    	
    iPDPossition = Vault.PropertyDefOperations.GetPropertyDefIDByAlias("PD.Possition")
    iPDUniqueFlag = Vault.PropertyDefOperations.GetPropertyDefIDByAlias("PD.UniqueFlag")
    
    'Taking the current position selection
    intPDPossition = oPropVals.SearchForProperty(iPDPossition).TypedValue.GetValueAsLookups.Item(1).Item
    
    'Creating an instance with the properties of the selected position
    Set oLookupObj = CreateObject("MFilesAPI.ObjVer")
    oLookupObj.SetIDs iOTJobPosition, intPDPossition, -1
    
    Set oObjectInfo = CreateObject("MFilesAPI.ObjectVersion")
    Set oObjectInfo = Vault.ObjectOperations.GetObjectInfo(oLookupObj, True, False)
    
    Set oBindProperties = CreateObject("MFilesAPI.PropertyValues")
    Set oBindProperties = Vault.ObjectPropertyOperations.GetProperties(oObjectInfo.ObjVer)
    
    szPDUniqueFlag = oBindProperties.SearchForProperty(iPDUniqueFlag).TypedValue.DisplayValue
    szPosition = oBindProperties.SearchForProperty(0).TypedValue.DisplayValue
    
    If Len(szPDUniqueFlag) > 0 Then
    	boolPDUniqueFlag = oBindProperties.SearchForProperty(iPDUniqueFlag).TypedValue.Value
    Else
    	boolPDUniqueFlag = False
    End If
    
    'If the position is unique, we look in the Employee object to see if there is already another one in this position
    If boolPDUniqueFlag Then
    	Set oSCs = CreateObject("MFilesAPI.SearchConditions") 
    
    	Set oSCClass = CreateObject("MFilesAPI.SearchCondition") 
    	oSCClass.ConditionType = MFConditionTypeEqual
    	oSCClass.Expression.DataPropertyValuePropertyDef = 100 
    	oSCClass.TypedValue.SetValue MFDatatypeLookup, iCLEmployee
    	oSCs.Add -1, oSCClass
    
    	Set oSearchCondition = CreateObject("MFilesAPI.SearchCondition")
    	oSearchCondition.ConditionType = MFConditionTypeEqual
    	oSearchCondition.Expression.DataPropertyValuePropertyDef = iPDPossition  
    	oSearchCondition.TypedValue.SetValue MFDatatypeLookup, intPDPossition
    	oSCs.Add -1, oSearchCondition
    
    	'Exclude current object from the search results
    	oSearchCondition.ConditionType = MFConditionTypeNotEqual
    	oSearchCondition.Expression.DataStatusValueType = MFStatusTypeObjectID
    	oSearchCondition.TypedValue.SetValue MFDatatypeInteger, objVer.ID
    	oSCs.Add -1, oSearchCondition
    
    	' Search for just the non deleted element
    	Set oSearchNonDeleted = CreateObject("MFilesAPI.SearchCondition") 
    	oSearchNonDeleted.ConditionType = MFConditionTypeEqual
    	oSearchNonDeleted.Expression.DataStatusValueType = MFStatusTypeDeleted
    	oSearchNonDeleted.TypedValue.SetValue MFDatatypeBoolean, False
    	oSCs.Add -1, oSearchNonDeleted
    
    	' Execute Search	
    	Set oSearchResults = Vault.ObjectSearchOperations.SearchForObjectsByConditionsEx(oSCs,MFSearchFlagNone, False) 
    
    	If oSearchResults.Count > 0 Then
    		Err.Raise MFScriptCancel, """" & szPosition & """ position is already filled !"
    	End If 
    End If

  • You can change the value list to an object type. That will allow you to add the suggested property that says whether the job type is unique or not.