It's all about the answers!

Ask a question

How can we use RDNG Extensions API to detemine the artifact type of the currently selected artifact?


0
1
Achla Sharma (31316) | asked Dec 05 '14, 9:01 a.m.
edited Dec 09 '14, 1:36 a.m.

We came across the latest RM Extensibility feature in CLM 5.0. We are trying to use the RM API to use customize a RRC widget  to determine the artifact type of the currently selected artifact. The code makes use of the ARTIFACT_TYPE constant.:

RM.Data.getAttributes(attrRef, function(attrResult) {


  if (attrResult.code != RM.OperationResult.OPERATION_OK){
   return;
  }

var attrs = attrResult.data[0];

document.getElementById("artifactType").innerHTML ="Artifact type  obtained : "+attrs.values[RM.Data.Attributes.ARTIFACT_TYPE];

}

On artifact selection the Artifact type appears as : Undefined.

Is any change required in the code?

Accepted answer


permanent link
Peter Morgenthaler (102815) | answered Jan 13 '15, 1:14 a.m.
edited Jan 13 '15, 1:15 a.m.
Hi,

Have a look at How to get the Artifact Type using the DOORS Javascript

This may answer your question.

Peter

Achla Sharma selected this answer as the correct answer

2 other answers



permanent link
Donald Nong (14.5k414) | answered Dec 09 '14, 1:22 a.m.
I hope this is just a simple mistake since we can only see so little of the code - the parameter passed into the function is "attrResult" but it is not used when referencing the ARTIFACT_TYPE constant and a variable "attrs" is used instead. I suppose "attrs" should have been "attrResult".

Comments
Achla Sharma commented Dec 09 '14, 1:53 a.m.

Hi Donald,

The "attrs" variable here refers to :
var attrs = attrResult.data[0];

I also tried adding the following snippet :
var documentType = new RM.ArtifactType('Document');
var refType = attrs.values[RM.Data.Attributes.ARTIFACT_TYPE];
        if(refType.equals(documentType))
        {
        // do some operation
        }

The equals operation throws an undefined type error.


permanent link
Steve Wood (1162) | answered Dec 21 '14, 4:10 p.m.
 Hi,

Sorry for the slow response.  I cannot see any reason why the code you posted would produce undefined.  Can you see by printing to the browser console what the "attrs" object is ?

Thanks,
Steve Wood.

DOORS Next Generation team.


Your answer


Register or to post your answer.