Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 55831

Change status and update a record

$
0
0

Hi, 

I customised a new button for "close as won" an opportunity. This button launch a dialog box and after that I woudl like to change the status from "open" to "won" and update the form. 

For that I wrote this code and nothing happens:

//Open the dialog

function openDialogProcess()
{
var DialogId = "BB4FAB91-D186-4A0C-91D3-DA2697E10F1B";
var url = Xrm.Page.context.getClientUrl() +
"/cs/dialog/rundialog.aspx?DialogId=" + DialogId + "&EntityName=opportunity&ObjectId=" + Xrm.Page.data.entity.getId();

window.open(url, ' ' , 'left=500,top=100,width=700,height=600,toolbar=1,resizable=0');
};

//Update the form

function updateForm(FormId) {
var form = { };
form.StateCode = { value: 0 };
form.StatusCode = { value: 1 };

SDK.JQuery.updateRecord(
Xrm.Page.data.entity.getId(),
form,
"Opportunity",
function () {
writeMessage("L'opportunité a été fermé comme gagné");

},
function () {
errorHandler("Erreur!!!!");

});
};

function errorHandler(error) {
writeMessage(error.message);
};

function writeMessage(message) {
var li = document.createElement("li");

setElementText(li, message);


output.appendChild(li);
};

If anyone could help me about it, I'll be gratefull 

Adry


Viewing all articles
Browse latest Browse all 55831

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>