Last active
February 3, 2017 09:59
-
-
Save synesthesia/8b868a35331e10fccc3d5b88b021bf58 to your computer and use it in GitHub Desktop.
CRM entity status weirdness - the old way
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// issue invoice | |
var setStateRequest = new SetStateRequest | |
{ | |
EntityMoniker = new EntityReference(Invoice.EntityLogicalName, invoice.Id), | |
State = new OptionSetValue((int)InvoiceState.Active), | |
Status = new OptionSetValue((int)invoice_statuscode.ReadyToIssue) | |
}; | |
Service.Execute(setStateRequest); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setStateToIssued: function (invoiceId) { | |
// workaround curly brace issue in Soap lib https://code.msdn.microsoft.com/SdkSoapjs-9b51b99a/view/Discussions | |
invoiceId = invoiceId.replace(/[{}]/g, ""); | |
var moniker = new Sdk.EntityReference("invoice", invoiceId); | |
var state = 0; //active | |
var status = 293750003; // Ready To Issue | |
var req = new Sdk.SetStateRequest(moniker, state, status); | |
Sdk.Q.execute(req) | |
.then(function () { | |
Xrm.Page.data.entity.save("saveandclose"); | |
}, function (error) { | |
common.log(error); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment