16. November 2015 15:34
.EntityState must be set to null, Creaded (for Create message) or Changed (for Update message)
// Rechnung erstellt nun noch Rechnungsprodukte generierne:
createdInvoiceId = result.InvoiceId;
// Wenn onlinestunden auf dem Ticket dann Rechnungsprodukt Stundensatz online Kurzbeschriebung Onlinestunden Ticket
var summeAktivitaetenOnline = GetArbeitsstundenOnline(Entity.IncidentId);
if(summeAktivitaetenOnline != null || summeAktivitaetenOnline != ""){
var newInvoiceDetail = new Object();
var productReference = new Object();
productReference.Id = "B87A8036-60E2-DF11-B1FC-001E4F38B5AB";
productReference.LogicalName = "product";
productReference.Name = "Online-Einheit à 15 Minuten";
newInvoiceDetail.ProductId = productReference;
var nextpositionsnummer = getNextPositionsnummer(createdInvoiceId);
newInvoiceDetail.OPD_positionsnummer_produkt_neu = nextpositionsnummer;
newInvoiceDetail.Itara_ics_shortdescription = "Online-Einheit à 15 Minuten";
newInvoiceDetail.OPD_Kurzbeschreibungenglisch = "Online unit at 15 minutes";
var onlineEinheiten = ((summeAktivitaetenOnline[0]*60)+summeAktivitaetenOnline[1])/15; //(summeAktivitaetenOnline*60)/15;
newInvoiceDetail.Quantity = parseFloat(onlineEinheiten).toFixed(2);
var invoiceReference = new Object();
invoiceReference.Id = createdInvoiceId;
invoiceReference.LogicalName = "invoice";
invoiceReference.Name = Entity.Title;
newInvoiceDetail.InvoiceId = invoiceReference;
var einheitReference = new Object();
einheitReference.Id = "F3172E7B-3373-4321-BFF0-06F1425A93A5";
einheitReference.Name = "Stk";
einheitReference.LogicalName = "uom";
newInvoiceDetail.UoMId = einheitReference;
var resultInvoiceDetail = SSDK.REST.createRecord(newInvoiceDetail, "InvoiceDetail");
if (resultInvoiceDetail.name == "Error") {
alert("Error: " + resultInvoiceDetail.message);
}
17. November 2015 11:53
17. November 2015 12:39
entity.EntityState = EntityState.Changed;