UNPKG

crm-sdk

Version:

Javasript Software Development Kit for Microsoft Dynamics CE Web API

22 lines (19 loc) 654 B
import WebAPI from "../webapi/WebAPI"; const update = superclass => class extends superclass { async save() { if (await this.isNew()) { return this.create(); } else if (Object.keys(this.changes).length !== 0) { return this.update(); } } async update() { const {changes} = this, primaryId = await this.getPrimaryId(), logicalName = this.logicalName; console.log(`Update ${logicalName} (${primaryId})`); await WebAPI.updateEntity(logicalName, primaryId, changes); this.changes = null; } }; export default update;