Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 3363

Duplicate an item through odata

$
0
0

Hi all,

 

I have a question on how to duplicate an item which is stored in the database through odata. I have an application where you can maintain materials, I already created a form with which you can create a new entry or change an existing one. For the creation I use the "createEntry" on the model and than set the bindingContext of the view to this. E.g.:

 

// create default properties

  var oProperties = {

  CREATED_ON: oDateFormat.format(new Date()),

  CREATED_BY: window.globalVariable,

  SOURCESYSTEM: this.oArgs.SOURCESYSTEM

  };

 

  // create new entry in the model

  this._oContext = oView.getModel().createEntry("/" + this.oArgs.MDMTYPE.toLowerCase(), {

  properties: oProperties,

  success: this._onCreateSuccess.bind(this)

  });

 

  // bind the view to the new entry

  oView.setBindingContext(this._oContext);

 

For the changing of an existing Item I use:

 

oView.bindElement({

     path: sPath

});

 

and then I save the changes back with "oModel.submitChanges()".

 

But now I like the user to be able to copy an existing item but save it as a new item. This would need a combination of the two because if I use the "change" method it will bind the existing material correctly on the view but when saving it would overwrite the 'copied' material instead of creating a new one. And I can use the createEntry option but then I will see an empty form without pre-binded values.

 

Any idea if there is a nice way for achieving something like this?

 

Kind Regards,

Nico van der Linden


Viewing all articles
Browse latest Browse all 3363

Trending Articles



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