Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

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.

0 votes



2 answers

Permanent link

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)
                    }
                })
            }
        })    
    })

1 vote

Comments

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

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...

0 votes

Your answer

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 12,015

Question asked: Oct 23, 5:46 a.m.

Question was seen: 323 times

Last updated: Oct 25, 2:29 a.m.

Confirmation Cancel Confirm