I did some work this afternoon to override the weights on elements by loading them in from a csv file. Thought you might find the code useful. You can set the weights manually in the dimension editor but I find that rerunning the associated TI process sometimes wipes what I did. So wanted to do from the process instead.
Basically, I added a column to the csv file that built the chart of accounts dimension. This column was called ‘Weight Override’. I filled it in with -1 where I wanted the subtotal to subtract the number. I set it to ‘String’ and ‘Other’. On the metadata tab below autogenerated section, I wrote the code as follows….
#For those which have the weight override column populated, delete it from its parent and re-insert it with the override column weight.
IF(vWeightOverride@<>”);
#Convert the weight override column to a numeric value as its currently set as a string
vWeightNumeric=Numbr(vWeightOverride);
DimensionElementComponentDelete(‘CoA PLC’,vPArent,vChildConv);
DIMENSIONELEMENTCOMPONENTADD(‘CoA PLC’,vPArent,vChildConv,vWeightNumeric);