web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Field values set to null after Oppty Reopening.

(0) ShareShare
ReportReport
Posted on by 407

Hi, I have two fields Actual Revenue and Actual Close date. On closing an Opportunity, values are set to this fields. When same record is reopen, it is observed that set values are set to empty.

On reopen Opportunity ribbon button ,I have code.

/// <reference path="SDK.WEBAPI.js" />
function ReOpenOpportunity(executionContext)//added
{
debugger;
var formContext = executionContext.getFormContext(); // added
var opptyId = formContext.data.entity.getId().replace('{', '').replace('}', '');//changed
var oppty = new Object();
oppty.aes_opportunityreopened = true;
SDK.WEBAPI.updateRecord(opptyId, oppty, "opportunities", function () { }, function () { });

}


this is SDK.WEBAPI.js

updateRecord: function (id, object, type, successCallback, errorCallback) {
///
/// Sends an asynchronous request to update a record.
///

////// A String representing the GUID value for the record to retrieve.
/// ////// A JavaScript object with properties corresponding to the Schema Names for
/// entity attributes that are valid for update operations.
/// ////// The Schema Name of the Entity type record to retrieve.
/// For an Account record, use "Account"
/// ////// The function that will be passed through and be called by a successful response.
/// Nothing will be returned to this function.
/// ////// The function that will be passed through and be called by a failed response.
/// This function must accept an Error object as a parameter.
/// this._stringParameterCheck(id, "SDK.WEBAPI.updateRecord requires the id parameter.");
this._parameterCheck(object, "SDK.WEBAPI.updateRecord requires the object parameter.");
this._stringParameterCheck(type, "SDK.WEBAPI.updateRecord requires the type parameter.");
this._callbackParameterCheck(successCallback, "SDK.WEBAPI.updateRecord requires the successCallback is a function.");
this._callbackParameterCheck(errorCallback, "SDK.WEBAPI.updateRecord requires the errorCallback is a function.");

if (type.slice(-1) != "s") {
type = type + "s";
}

var req = new XMLHttpRequest();
req.open("PATCH", encodeURI(this._WebAPIPath() + type + "(" + id + ")"), true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.onreadystatechange = function () {
if (this.readyState == 4 /* complete */) {
req.onreadystatechange = null;
if (this.status == 204 || this.status == 1223) {
successCallback();
}
else {
errorCallback(SDK.WEBAPI._errorHandler(this));
}
}
};
req.send(JSON.stringify(object));
},
deleteRecord: function (id, type, successCallback, errorCallback) {
///
/// Sends an asynchronous request to delete a record.
///

////// A String representing the GUID value for the record to delete.
/// ////// The Schema Name of the Entity type record to delete.
/// For an Account record, use "Account"
/// ////// The function that will be passed through and be called by a successful response.
/// Nothing will be returned to this function.
/// ////// The function that will be passed through and be called by a failed response.
/// This function must accept an Error object as a parameter.
/// this._stringParameterCheck(id, "SDK.WEBAPI.deleteRecord requires the id parameter.");
this._stringParameterCheck(type, "SDK.WEBAPI.deleteRecord requires the type parameter.");
this._callbackParameterCheck(successCallback, "SDK.WEBAPI.deleteRecord requires the successCallback is a function.");
this._callbackParameterCheck(errorCallback, "SDK.WEBAPI.deleteRecord requires the errorCallback is a function.");

if (type.slice(-1) != "s") {
type = type + "s";
}

var req = new XMLHttpRequest();
req.open("DELETE", encodeURI(this._WebAPIPath() + type + "(" + id + ")", true));
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.onreadystatechange = function () {

if (this.readyState == 4 /* complete */) {
req.onreadystatechange = null;
if (this.status == 204) {
successCallback();
}
else {
errorCallback(SDK.WEBAPI._errorHandler(this));
}
}
};
req.send();

},

*This post is locked for comments

I have the same question (0)
  • Verified answer
    AM-22040756-1 Profile Picture
    407 on at

    Found as OOB feature. hence closing the Q

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans