It's all about the answers!

Ask a question

DNG : In the WebUI, if the Approved Artifact is changed then change the state to New automatically


Shwetha G (265710) | asked Oct 23, 5:46 a.m.
edited Oct 23, 5:47 a.m.

Hi Team,


I have a usecase wherein the state of the DNG artifact should move to New state when there is a modification in the artifact. 

E.g: There is an artifact which is in Approved state and there is a minor change to the artifact, which when made, should automatically move the state to New state.

Is this possible on the Web UI ?

Thanks.

2 answers



permanent link
Antje Rößle-Tuchel (59415) | answered Oct 23, 6:05 a.m.

Hi,


I have created a widget with nothing in and the code on the js.file looks like this:

let oldArtRef=[]

RM.Event.subscribe(RM.Event.ARTIFACT_SAVED, async function(artRef){
    console.log (oldArtRef)
    console.log (artRef)
    if (oldArtRef[0]){
        if (oldArtRef[0].uri != artRef[0].uri){
            oldArtRef = await resetProcessState(artRef)
        }
    }
    else{
        oldArtRef = await resetProcessState(artRef)
    }      
})


// Reset workflow state for the changed artifact to "New", if the artifact type is one of "Software Requirement" or "Required Value"
async function resetProcessState(artRef){
    return new Promise((resolve, reject)=> {
        RM.Data.getAttributes(artRef, [RM.Data.Attributes.ARTIFACT_TYPE], async function(result){
            console.log (result.data)
            var attrs = result.data[0]
            if (attrs.values["http://www.ibm.com/xmlns/rdm/rdf/ofType"].name==="Software Requirement" ||
            attrs.values["http://www.ibm.com/xmlns/rdm/rdf/ofType"].name==="Required Value"){
                let artifactAttributes = await new RM.ArtifactAttributes();
                let attributeValues = await new RM.AttributeValues();
                artifactAttributes.ref = artRef[0];
                artifactAttributes.values = attributeValues
               
                // Reset some attribute values
                attributeValues["State (Requirements Workflow)"]="New";
                console.log (attributeValues)
                console.log (artifactAttributes)
                await RM.Data.setAttributes(artifactAttributes, async function(result){
                    if(result.code === RM.OperationResult.OPERATION_OK){
                        resolve(artRef)
                    }
                    else{
                        reject(result)
                    }
                })
            }
        })    
    })


Comments
Shwetha G commented Oct 24, 1:09 a.m.

Hello Antje,


Thanks for your response. But I have few minor questions:

1. How to configure this in the server ?
2. It has to keep on running in the DNG server right ? How to set it up ?

Thanks in advance.


permanent link
Antje Rößle-Tuchel (59415) | answered Oct 25, 2:29 a.m.

On the same server as Jazz is located, there is a path to locate separate files for widgets. I do not know how this path is linked.

Then there is an xml-file where all widgets are located:

<rdf:RDF
    xmlns:ju="http://jazz.net/ns/ui#"
    xmlns:dc="http://purl.org/dc/terms/">
    <ju:catalog-entry>
        <dc:description>Copy artifacts between different streams</dc:title>
        <ju:icon rdf:resource="./dropins/copy_artifacts/icon_add_link_to_artifact.png"/>
        <ju:thumbnail rdf:resource="./dropins/copy_artifacts/thumbnail_add_link_to_artifact.png"/>
        <ju:preview rdf:resource="./dropins/copy_artifacts/thumbnail_add_link_to_artifact.png"/>
        <ju:gadget rdf:resource="./dropins/copy_artifacts/copy_artifacts.xml"/>
        <ju:category>Requirements</ju:category>
    </ju:catalog-entry>
</rdf:RDF>

The widget itselve has at least 3 files:
one xml-file lookink like this:

<?xml version="1.0" encoding="UTF-8" ?>
<Module specificationVersion="1.0">
    <ModulePrefs title="Add enums to RM-artifacts">
        <Require feature="dynamic-height"/>
        <Require feature="com.ibm.rdm.rm.api"/>
        <Optional feature="com.ibm.team.gc.gcm.api"/>
    </ModulePrefs>
    <Content type="html" href="add_enums_to_artifact.html" />
</Module>

one html-file:
<form class="row  g-1 p-2"  id="copyArtifactForm">
<script type="text/javascript" src="add_enums_to_artifact.js"></script>

and the js-file named "add_enums_to_artifact.js" with the code above mentioned...

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.