Custom object numbering scheme

Custom object numbering scheme

martin_obadalek
Explorer Explorer
1,914 Views
10 Replies
Message 1 of 11

Custom object numbering scheme

martin_obadalek
Explorer
Explorer

Hello,

 

I am looking for a solution how to create new custom object with generated name using custom numbering scheme e.g. custom object is named REQUEST with number REQ-00001

Any idea ?

 

Thank you.

0 Likes
Accepted solutions (2)
1,915 Views
10 Replies
Replies (10)
Message 2 of 11

Markus.Koechl
Autodesk
Autodesk
Accepted solution

Hi Martin,

you can use a file numbering scheme to number COs as well.

In this example the name of the numbering scheme simply equals the category of the object. With that you can even have separate numbering schemes for different COs, e.g. Request, Classes, etc...

 

2 Steps are required: 1) filter available numering schemes according your category and 2) use this scheme to create the number

 

1) filter 

function GetNumSchms {

..... add the lines to the default function.... after the $list is filled:

#Filter list or share it, according required dialog/category=numschm type
$mWindowName = $dsWindow.Name
switch($mWindowName)
{
"FileWindow"
{
$Global:NumSchmsList = $list
}

"FolderWindow"
{
$Global:NumSchmsList = $list
}

"CustomObjectWindow"
{
$mCat = $dsWindow.FindName("Categories").SelectedValue.Name
$list = $list |? { $_.Name -eq $mCat}
$dsWindow.FindName("NumSchms").SelectedIndex = 0
}

default
{
#$list = $list |? { $_ -eq $UIString["MSDCE_Num03"]}
$dsWindow.FindName("NumSchms").SelectedIndex = 0
}
}
return $list
}

 

 

2) Create new name - if numbering scheme exists, it will be used, if not - just use the title as name

 

function GetNewCustomObjectName {

$dsDiag.Trace("--GetNewObjectName Default=all categories---")
IF($dsWindow.Findname("NumSchms").SelectedIndex -eq 0) {
#$objectName = GenerateObjectNumber
$Prop["_XLTN_IDENTNUMBER"].Value = GenerateObjectNumber #fill the (readonly) field
}

$objectName = $dsWindow.FindName("txtName").Text
$dsDiag.Trace("--- txtName returns $objectName ")
IF ($objectName -eq "") {
$objectName = $Prop["_XLTN_TITLE"].Value
$dsDiag.Trace("--- Title gets the new object name")
}

$dsDiag.Trace("--- GetNewCustomObjectName returns $objectName")
return $objectName
}

 

We are sharing a full featured example environment "Vault 2016 Quickstart" with our channel partners/resellers. Let me know, in case you don't get access to it.

 

Regards,

Markus



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes
Message 3 of 11

Patrick.Gruber
Enthusiast
Enthusiast

Hi martin.obadalek,

I have just made a quick example by using the free tool powerVault, a set of commandlets for powershell:

 

function Add-CustomEntity($customType, $name) {
    $entityDefId = $vault.CustomEntityService.GetAllCustomEntityDefinitions() | where { $_.DispName -eq $customType} | select -ExpandProperty "Id"
    return $vault.CustomEntityService.AddCustomEntity($entityDefId, $name)
}

function Generate-CustomEntityName($type) {
    if($type -eq "REQUEST") {
        return "REQ-00001"
    }
}

Open-VaultConnection 
$customObjectType = "REQUEST"
$name = Generate-CustomEntityName $customObjectType
Add-CustomEntity $customObjectType $name

I think there are no numbering schemes in Vault for custom entities as far as I know, therefore I added a function which "generates" a name for you. But if you want to, you should implement this one yourself I just wrote an example.

 

Please mark this response as "Accept as Solution" if it answers your question.
If you have found any post to be helpful, even if it's not a direct solution, then please provide that author kudos!
😉
The author,
Patrick

coolOrange
www.coolOrange.com
0 Likes
Message 4 of 11

kimhendrix
Enthusiast
Enthusiast

Patrick,

can you modify your example, assuming a Numbering scheme exist?

I'm wanting to customize the CreateCustomObjects script, to add multiple Objects based on a value in the XAML file, 

 

ie: QtytoReserve = 6

 

the script would create the 1st one, then run through a for loop for the additional 5 objects.

 

thanks!

Kim

0 Likes
Message 5 of 11

Anonymous
Not applicable

@Markus.Koechl I know it is an old post - but is it possible to do above without programming?

0 Likes
Message 6 of 11

Markus.Koechl
Autodesk
Autodesk

@Anonymous: sure, that's possible by replacing the custom object's new name with a number, retrieved from the numbering service.

$name = $vault.DocumentService.GenerateFileNumber(NumID, $NumGenArgs)


Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes
Message 7 of 11

J_Dumont
Advocate
Advocate

Hi Markus,

 

Good morning.

Can you provide me with some more detailed info on this?

I want to add that the custom object uses auto-numbering.

 

I'm not sure where I add the code you posted.

 

 

0 Likes
Message 8 of 11

Markus.Koechl
Autodesk
Autodesk

@J_Dumont: Enabling auto-numbering for a custom object works out of the box if you create a numbering scheme name that matches the custom object's category name.



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
0 Likes
Message 9 of 11

J_Dumont
Advocate
Advocate

Hi Markus,

 

Thank you for the reply.

I've created a numbering scheme for Files that matches the category name of the custom object, but it does not work.

I then deleted the scheme for files and created one for Change Orders, which also did not work.

 

FYI: I'm using Vault Pro 2025

0 Likes
Message 10 of 11

Markus.Koechl
Autodesk
Autodesk
Accepted solution

Hi @J_Dumont , you must use a file numbering scheme type for folders and custom objects. Does your Vault have an assignment rule for the custom object category? If the category is not set on creation, the name mapping will not initialize. Please follow the steps documented in VDS Tutorial Chapter 06; Step 9 instructs how to configure the mapping.



Markus Koechl

Solutions Engineer PDM, Autodesk Central Europe
Message 11 of 11

J_Dumont
Advocate
Advocate

Hi Markus,

 

Thank you for your assistance. I was able to get the auto-numbering to work.

 

0 Likes