RallyTools / rally-node

A Node.js Toolkit for Accessing Rally's Webservice API
MIT License
53 stars 25 forks source link

How to update `Automated Environments` #39

Closed amiya-pattnaik closed 6 years ago

amiya-pattnaik commented 6 years ago

Hi, for a particular testcase i want to update the custom field Automated Environments to Stage etc. I am able to update other field but not theAutomated Environments through Update method. Please guide me. here is my code. Thanks.

request.update({
        ref: '/testcase/23772',
        data: {
            Priority:       'Critical',          //this is getting updated
            Method:      'Automated',     //this is getting updated
            Type:          'Functional',              //this is getting updated
            c_AddtoRegression: false,          //this is getting updated
            c_AutomatedEnvironments: JSON.stringify({ _tagsNameArray: [{"Name": "Development", "_ref": "/allowedattributevalue/XXXXXXXX"}], })   // NOT getting updated

        },
      }, function(error, result) {
            if(error) {
                console.log(error);
            } else {
              //console.log(result.Object);
              console.log('*** testcase updated successfully ! ***');
            }
        });   //end of update block

below is the JSON object of custom field

"c_AutomatedEnvironments": {
            "_rallyAPIMajor": "2",
            "_rallyAPIMinor": "0",
            "_ref": "https://rally1.rallydev.com/slm/webservice/v2.0/TestCase/xxxxxxx/c_AutomatedEnvironments",
            "_type": "AllowedAttributeValue",
            "_tagsNameArray": [{
                "Name": "Stage",
                "_ref": "/allowedattributevalue/XXXXXXXX"
            }],
            "Count": 1
        },
krmorse commented 6 years ago

Multivalue fields are updated much the same way you would handle Tags or any other collection- the value should be an array of objects, with each containing a _ref.

 data: {
    c_AutomatedEnvironments: [
        { "_ref": "/allowedattributevalue/XXXXXXXX" }
    ]
 }