Oscar
Oscar

Reputation: 1

TFS 2012 Web Access Work Item Custom Control

I´m developing a TFS 2012 web access custom control and I need to change some workitem field values when the save workitem button is clicked.

I’ve just developed the same custom control for Visual Studio and I’ve performed these changes in the IWorkItemControl.FlushToDatasource method but I don't know how to achieve the same at web access control.

I’ve tried to change the workitem field values in the invalidate function when the workitem is being saved,

invalidate: function (flushing) {
    if (this._workItem.isSaving()) {
         this._workItem.getField("FieldName").setValue("newValue");
    }
},

But it does not work, although the changes made while saving the workitem are included in the list of updated fields, they are not saved.

Any idea how can it be implemented by using the Javascript API?

Thanks.

Oscar

Upvotes: 0

Views: 739

Answers (1)

Salih KARAHAN
Salih KARAHAN

Reputation: 329

Can you try this:

    _control: null,
    _init: function() {
        alert("_init() called!");

        debugger;
        if (this._workItem) {
            var originalEstimate = this._workItem.getField("Microsoft.VSTS.Scheduling.OriginalEstimate").getValue();
            alert('OriginalEstimate value is ' + originalEstimate);
            console.log('this in _init');
            console.log(this);
        } else {
            alert('_workItem is null or undefined!');
            console.log('this in _init');
            console.log(this);
        }

        this._base();
        this._control = $("<div style='width:100%;height:100%;background-color:lightblue;'><button type='submit'>CLICK ME!</button></div>").appendTo(this._container).bind("click", delegate(this, this._onClick));
    },

    invalidate: function(flushing) {
        alert("invalidate(flushing) called!");
        var value = this._getField().getValue();

        debugger;
        if (this._workItem) {
            var originalEstimate = this._workItem.getField("Microsoft.VSTS.Scheduling.OriginalEstimate").getValue();
            alert('OriginalEstimate value is ' + originalEstimate);
            console.log('this in _init');
            console.log(this);
        } else {
            alert('_workItem is null or undefined!');

            console.log('this in _init');
            console.log(this);
        }

        alert(value);
    },

    clear: function() {
        alert("clear() called!");
    },

    _onClick: function() {
        alert("Butona tıklandı!");
    }

Upvotes: 2

Related Questions