I
did not find a way to write new entries into a profile reference attribute if
this one can contain several items.
I
added a reference attribute TriggeringConditions that can take several object
entries of type Triggering Condition to FailureMode in a detached FMEA.
I
could read and print out the present easily via = Operator, e.g.
alert("Existing
TC in array = " + plainfailure.user_triggeringconditions[j]); // print out what has been in the profile attribute before
But
trying to write something new crashed the script with null pointer failure
message (I've seen other messages, too, but it crashes Always):
plainfailure.user_triggeringconditions[j]
= cause; // cause is an object of type Triggering Condition, same type as was in before
I
am sure that the type of object I am trying to put in the array cell was correct (I compared
it to a valid Triggering Condition that I had put into the profile attribute before, by hand). I am also sure that the field in the array where I'm writing to actually exists (my code snippet is part of a for loop indexing over j, but for experimenting I forced j to be 0 in every case, and at
this position was the Triggering Condition I just read before and printed out in the message box, so there must be at least one entry in this array when I call this line of code).
I
was unsure whether I am allowed to write to profile reference attributes from a
script at all, so I did another experiment for comparison, this time with a reference attribute that can
handle just a single entry (i.e. this time it is not an array anymore):
alert("Existing
TC in single object reference property = " + plainfailure.user_singletriggeringcondition);
// print out what has been in the attribute so far
plainfailure.user_singletriggeringcondition
= cause; // overwrite it with a new object of same type Triggering Condition
This
time, read and write worked without problems!
What
am I doing wrong, or is what I want simply not possible?