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

How to refer to items in a value list by their 'Name'

Hi, I've got some code in a workflow where depending on one source property, we're setting another destination property 'Type'

'Type' is a value list which contains:

Programme, ID = 1

Project, ID = 2

etc

Previously I was doing that via just setting the ID number. I know that Project is ID=2 in the Type value list, so I have that ID number hard coded in the script

However, the vault is due to be deployed to production via content replication rather than transferring an .MFB so we've been told that all ID number references should be avoided and everything needs to use aliases instead, as the ID numbers may get shuffled around in the transition and won't stay in the same order

 

So, How can I avoid using the ID? I know the value in the source property will be 'Project', so do I have to construct a search to find the item within the value list that matches, then I can get the (new) ID number, and use that ID as previously? or is there some better approach

Many thanks

Parents
  • Many thanks both

    The original version used a hardcoded ID,

    oOnePropVal.TypedValue.SetValue MFDataTypeLookup, 2

    Instead, we now find the Value List's ID by its Alias, 
    Then find the Value List ITEM's ID (from within that value list) by its hardcoded GUID
    Then use that ID in place of the hardcoded one

    Dim lValueListID : lValueListID = Vault.ValueListOperations.GetValueListIDByAlias("H.ValueList.ProjectType")
    Dim lValueListItemID : lValueListItemID = Vault.ValueListItemOperations.GetValueListItemIDByGUID(lValueListID, "6AEC39DE-7434-4FC9-AF8B-94E56A39B0E7")
    oOnePropVal.TypedValue.SetValue MFDataTypeLookup, lValueListItemID

Reply
  • Many thanks both

    The original version used a hardcoded ID,

    oOnePropVal.TypedValue.SetValue MFDataTypeLookup, 2

    Instead, we now find the Value List's ID by its Alias, 
    Then find the Value List ITEM's ID (from within that value list) by its hardcoded GUID
    Then use that ID in place of the hardcoded one

    Dim lValueListID : lValueListID = Vault.ValueListOperations.GetValueListIDByAlias("H.ValueList.ProjectType")
    Dim lValueListItemID : lValueListItemID = Vault.ValueListItemOperations.GetValueListItemIDByGUID(lValueListID, "6AEC39DE-7434-4FC9-AF8B-94E56A39B0E7")
    oOnePropVal.TypedValue.SetValue MFDataTypeLookup, lValueListItemID

Children
No Data