sdkrallywsapi

How to save WorkItemsAffected to a Risk


How do I save or link a feature item to an existing risk? I was trying to post but it did not work:

    var url = "https://rally1.rallydev.com/slm/webservice/v2.x/risk/" + riskRecord.data.ObjectID + "/workitemsaffected";
    return Q.Promise(function (resolve, reject) {
        $.ajax({
            url: url,
            method: 'POST',
            dataType: 'json',
            data:"/portfolioitem/feature/" + portfolioItemObjectID,
            headers: {
                'Content-Type': 'application/json'
            },
            xhrFields: {
                withCredentials: true
            },
            success: function (item) {
                resolve(item.QueryResult.Results);
            },
            error: function (e) {
                console.error(e);
                resolve(false);
            }
        });
    });

Thank you!!


Solution

  • Actually, setting the ref of WorkItemsAffected saves the WorkItemsAffected to Risk.

    riskRecord.set('WorkItemsAffected', [{
                    _ref: "/portfolioitem/feature/" + valueRecord.data.PortfolioItemObjectID
                }]);
    

    Thanks!