It's all about the answers!

Ask a question

Getting the resourceURI for a DNG module via the RM API


Anthony Weber (112) | asked May 23 '19, 8:21 a.m.

 Is there a way to retrieve a RM module's resourceURI via the RM.Data.Attributes (for example) interface?  I've looked through the API documentation and have not found a way yet.  In DNG, the value I'm looking for is in dataSources.artifact.itemId


It would be nice if I could retrieve this via a plugin within RM.

Thanks,
Tony

One answer



permanent link
Anthony Weber (112) | answered May 24 '19, 8:55 a.m.

 OK.  Figured it out with some help from some borrowed code. from Andrew Lloyd's post on Jan 21, 2015...


Andrew Lloyd (5346| asked Jan 21 '15, 1:50 a.m. 
edited Jan 22 '15, 10:27 p.m.

Here's his code with the needed mod to post the resourceURI (refer to his post for the rest of the plugin (i.e., the xml part))
$(function() {        
    RM.Event.subscribe(RM.Event.ARTIFACT_SELECTED, function(selected) { 
        if (selected.length == 1) { 
            selectedArtifact = selected[0]; 

            RM.Data.getAttributes(selectedArtifact, [RM.Data.Attributes.CONTAINING_MODULE], function(attrResult) { 
                if (attrResult.code != RM.OperationResult.OPERATION_OK) { 
                    alert('get containing module failed in getContainingModule'); 
                    return; 
                } else { 
                    var module = attrResult.data[0].values[RM.Data.Attributes.CONTAINING_MODULE]; 


                    RM.Data.getAttributes(module, function(result) { 
                        if (result.code != RM.OperationResult.OPERATION_OK) 
                        { 
                            alert('get attributes of module failed in getContainingModule'); 
                            return; 
                        } 
                        var moduleAttributes = result.data[0]; 

                        $('#descript').val(moduleAttributes.values[RM.Data.Attributes.DESCRIPTION]); 
                        $('#identity').val(moduleAttributes.values[RM.Data.Attributes.IDENTIFIER]); 
                        $('#moduleName').val(moduleAttributes.values[RM.Data.Attributes.NAME]);
var uri                 = module.toUri();
var uriPieces           = uri.split('/');
var len = uriPieces.length;

                        $('#info').val(uriPieces[len - 1]);      // this val posts to a fourth box in the plugin.
                    }); 
                } 
            }); 
        } else { 
            $('#descript').val(''); 
            $('#identity').val('N/A'); 
            $('#moduleName').val('Select a single artifact.'); 
        } 
    }); 
}); 

Your answer


Register or to post your answer.