Showing results for 
Search instead for 
Did you mean: 

Create Parts from Database Table with minimal code


There are situations when you want to create parts off of a database table (or dataset based on query) and have its properties get their values from the columns of the resulting dataset. The base Rulestream install comes with 2 powerful methods that help you achieve this with minimal (or no) coding. Here are the steps:


1) Create a subpart whose quantity formula should be something like:

Result = ComponentPartsQuantity("MyDataSet1", "TableName")

Here, the first argument is to give a name to your resulting dataset which you will need later on. This means, you can create as many datasets (driving different subparts) with different names. The second argument is either a table/view name or a query

2) Create a valid partfamily with properties that will hold the values of columns from this dataset. Then, each of the properties would have one line of code like following:

Result = ComponentPartValue("MyDataSet1", SubpartID, "ColumnName")

Here, the first argument tells the function which named dataset do you want to get your value from. Second argument is to tell it which row number to get its value from and the third argument is to tell it which column holds the value I want


That's it! Only 1 line of code in subpart quantity formula 1 line in each of the properties and you now have a subpart that holds parts associated with a table/view or query.




Re: Create Parts from Database Table with minimal code


Dharmesh, this sounds really cool ! Thank you for mentioning ComponentPartsQuantity and ComponentPartValue functions whicn I never used before Smiley Happy

Probably this approach together with this one could be good alternative choise of creating parts and filling the properties.