Community
Vault Customization
Share your knowledge, ask questions, and explore popular Vault API, Data Standard, and VBA topics related to programming, creating add-ins, or working with the Vault API.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

new item number

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
Anonymous
1191 Views, 6 Replies

new item number

Hi,

my item is a part, import from an ERP-System, the given name has to be the ItemNum.

I generat it by ItemService.AddItemRevision(5).

I try to rename the item by

itemNew = ItemService.EditItem(item.RevId) and ItemService.AddItemNumber(itemNew.MasterId, numS.SchmID,

new string[] { "name" });

therefore I am intending to create a new NumSchm numS, but the result is always error nr. 137 (One of the inputs to the service call is incorrect)

what is wrog in

 

try

{

  NumSchm numberingScheme = new NumSchm();

  numberingScheme.Name = "KS_ERP_Scheme";

  numberingScheme.IsAct = true;

  CodeWord partWord = new CodeWord();

   partWord.Code = "";

  PredefListField listField = new PredefListField();

  listField.Name = "Type";

  listField.FieldTyp = Autodesk.Connectivity.WebServices.FieldType.FreeText;

  listField.CodeArray = new CodeWord[] { partWord };

  listField.DfltVal = partWord.Code;

  // create a delimiter field

  DelimField delimiterField = new DelimField();

  delimiterField.Name = numberingScheme.Name;

  delimiterField.FieldTyp = Autodesk.Connectivity.WebServices.FieldType.FreeText;

  delimiterField.DelimVal =  ';

  // create an autodenerated field

  AutogenField autogenField = new AutogenField();

  autogenField.FieldTyp = Autodesk.Connectivity.WebServices.FieldType.FreeText;

  autogenField.Name = "";

  autogenField.ZeroPadding = false;

  numberingScheme.FieldArray = new AWeb.NumSchmField[] { listField, delimiterField, autogenField };

  NumSchm numS = m_ItemService.AddNumberingScheme(numberingScheme);

}

catch (Exception ex)

 {  // 137 bei Connectivity.Web.Services.ItemService.AddNumberingScheme(NumberingSchemeDescription nsd

string sMessage = ex.Mesage; }

 

thanks

Erika

6 REPLIES 6
Message 2 of 7
Redmond.D
in reply to: Anonymous

Why not just add the numbering scheme through the Vault Explorer UI?

Go to Tools -> Administration -> Vault Settings -> Behaviors -> Define Custom Numbering Schemes.

 

If you must do it through code I still suggest first creating it through the UI.  Next go to code and call GetNumberingSchemesByType to find the NumSchm object for the scheme you just created.  Serialize it to XML and it will show you how what all the values should be set to.



Doug Redmond
Software Engineer
Autodesk, Inc.

Message 3 of 7
Anonymous
in reply to: Anonymous

ok I did.

The result: In Vault, I'm not able to change the default value of the freetext scheme.

In my app: because I realized, that only set the freetext scheme to application default,

the new part will have the number specified by the default value and it is not possible to change it

by givving Item.ItemNum a new value

I made the following steps:

                freeText.DfltVal = myNumber;

                schemaERP.FieldArray[0] = freeText;

                m_ItemService.UpdateNumberingScheme(schemaERP);

                m_ItemService.SetDefaultNumberingScheme(schemaERP.SchmID);

first time I succeeded, second time, I received error 266 (NumberingSchemeInUse)

It won't work to create a freetext scheme for each new article from ERP (I'm unable to delete schemes in use).

Is it possible to clone the behaviour of the renaming wizzard?

which steps are to do?

 

Message 4 of 7
Redmond.D
in reply to: Anonymous

Can we back up a bit.

What problem are you trying to solve?  What is the workflow?

 

Can you post a UI screenshot of the numbering scheme that you are using?



Doug Redmond
Software Engineer
Autodesk, Inc.

Message 5 of 7
Anonymous
in reply to: Anonymous

Hi Doug,

The Workflow:

My dll is an interface to any ERP-software (Navision, …), to exchange data (export and import) of items (part or assembly), the relevant data are configured by a file, data exchange is done by 2 sql tables in a separate database.

ERP can create a new part and specifies an item number and therefore the new item in Vault must have this number as ItemNum.

My first idea: clone the renaming wizard in vault, but the Api did not help me find the appropriate functions.

My next idea: use a freetext schema.

In Vault: I set to Default the numbering schema “Mapped” (an existing freetext schema).

The first new part gets the itemnum “Default”, this is the default value of the scheme, I’m not able to edit the value.

The next new part gets the itemnumber “100072”, this value meets the previous numbering scheme.

what is the purpose of a numbering scheme with freetext?

In Vault, I see the scheme “Mapped” is still the default scheme, but because it is use, it is no longer editable. (see Doc1)

In c#-souce: I used a numbering scheme with freetext, I created by myself (in Vault) (see Doc2)

I updated the default value with my number given from ERP, set the scheme to default and created the item with the appropriate number. The next time, I tried the same, but I received error 266 (NumberingSchemeInUse)

What is the default value supposed to be good for?

Autodesk.Connectivity.WebServices.NumSchm schemaERP

Autodesk.Connectivity.WebServices.FreeTxtField freetext

freeText.DfltVal = myNumber;

schemaERP.FieldArray[0] = freeText;

ItemService.UpdateNumberingScheme(schemaERP);

ItemService.SetDefaultNumberingScheme(schemaERP.SchmID);

The conclusion: I have to create a new numbering scheme for each new part, isn’t it?

But because it is not possible to delete a numbering scheme in use, this won’t work.

Therefore I think, I have to return to my first idea.

Please can you tell me the steps, I have to do?

Erika

Message 6 of 7
Redmond.D
in reply to: Anonymous

You want to take a number from another system and set that exact value as your item number.

The Mapped numbering scheme is the one you want do use.  No need to modify that scheme. 

 

The mapped scheme requires that you pass in text when you generate the number.  The resulting number is the same as the text you pass in since the scheme is just a single free text field.

 

Back to your original code, the AddItemNumber call needs to pass in the mapped numbering scheme ID for the second parameter.  The third parameter needs to be the number from the ERP system.

 

ItemService.AddItemNumber(itemNew.MasterId, mappedNumSchm.SchmID,

new string[] { numberFromErp });




Doug Redmond
Software Engineer
Autodesk, Inc.

Message 7 of 7
Anonymous
in reply to: Anonymous

Hi Doug,

 

Thank you.

I did, but I forgot to update item.ItemNum with the result of AddItemNumber.

Now it works

Erika

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report