Page 1 of 1

Altering element from N to C and attribute values

Posted: Thu Feb 19, 2015 1:19 pm
by buncikp
Hello,
Have you ever noticed that when adding an N-element to different N-element (future parent) to form a consolidation (thus altering the future parent element from N to C "automatically") will cause loss of attributes on the future parent element? I believe this method worked fine in versions <=10.1. Now in >=10.2 it seems that something is different?
Example (pseudocode):
1) Let's create future parent first as N element and set some attribute values

Code: Select all

DimensionElementInsertDirect(dimName, '', 'future parent', 'N');
AttrInsert(dimName, '', 'test n attr', 'n');
AttrPutN(100, dimName,  'future parent', 'test n attr');
Now we should have "future parent" in our dimension with attribute value set.

2) Now let's create new element and insert it as a child of future element. Inserting element as a child to N-element should alter N-element to C-element.

Code: Select all

DimensionElementInsertDirect(dimName, 'child', '', 'N');
DimensionElementComponentAddDirect(dimName, 'future parent', 'child', 1);
Now we have C-element "future parent", but we have lost attribute value on it.
Is it just me seeing this or others? Do you have any clue why this is happening?
Thank you

Re: Altering element from N to C and attribute values

Posted: Thu Feb 19, 2015 9:16 pm
by BrianL
When you change an element from leaf to consolidated (in either direction) you are essentially deleting the leaf element and creating new consolidated element. There was a bug in 10.1 where the direct dimension edit TI functions did not correctly implement this.

Would you really want cube data to persist after changing an element from leaf to consolidation and adding child elements? That could lead to incorrect values in your data.

Re: Altering element from N to C and attribute values

Posted: Fri Feb 20, 2015 8:44 am
by buncikp
BrianL wrote:When you change an element from leaf to consolidated (in either direction) you are essentially deleting the leaf element and creating new consolidated element. There was a bug in 10.1 where the direct dimension edit TI functions did not correctly implement this.

Would you really want cube data to persist after changing an element from leaf to consolidation and adding child elements? That could lead to incorrect values in your data.
Hello Brian,
I'm quite sure that the attribute values persisted the change in 9.5.X versions. I have tried it now and I have realized that this is happening due to usage of xxxDirect functions - new to TM1 10.X (direct commit is provided with each metadata change). If you use traditional non-direct functions, the attribute value is retained correctly. Of course data on the parent node will be lost as they are subject to aggregation calculation.

Re: Altering element from N to C and attribute values

Posted: Fri Feb 20, 2015 1:51 pm
by tomok
buncikp wrote:I have tried it now and I have realized that this is happening due to usage of xxxDirect functions - new to TM1 10.X (direct commit is provided with each metadata change).
A nice little nugget of information you should have included in the original post.

Re: Altering element from N to C and attribute values

Posted: Fri Feb 20, 2015 1:54 pm
by qml
tomok wrote:A nice little nugget of information you should have included in the original post.
He did, in his code:
buncikp wrote:

Code: Select all

DimensionElementInsertDirect(dimName, 'child', '', 'N');
DimensionElementComponentAddDirect(dimName, 'future parent', 'child', 1);

Re: Altering element from N to C and attribute values

Posted: Fri Feb 20, 2015 2:15 pm
by tomok
Yes. sorry.

Re: Altering element from N to C and attribute values

Posted: Mon Mar 02, 2015 8:45 pm
by paulsimon
Hi

I am not sure if it will help but try including DimensionUpdateDirect(DimName); in the Epilog

Regards

Paul Simon