Moving an Object Body

You can move an object body from one KiiObject to another. Moving an object body can be achieved within a scope or across scopes (e.g., moving an object body from a KiiObject in the application scope to a KiiObject in the user scope).

The following conditions must be met in order to move an object body:

  • You have the read and write permissions on both the source and target KiiObjects.
  • The source and target KiiObjects must exist when you move an object body.
  • The source KiiObject must have an object body.

If the target KiiObject has an object body, it will be replaced with the newly moved object body. If you move an object body that has been published, the object body becomes inaccessible.

Here is an example of moving an object body.

  • var sourceObject = KiiObject.objectWithURI("Set the URI of an existing KiiObject here");
    var targetObject = KiiObject.objectWithURI("Set the URI of an existing KiiObject here");
    var targetObjectUri = targetObject.objectURI();
    
    sourceObject.moveBody(targetObjectUri, {
      success: function(theSrcObject, theTgtObjectUri) {
        // Do something.
      },
      failure: function(theSrcObject, theTgtObjectUri, errorString) {
        // Handle the error.
      }
    });
  • var sourceObject = KiiObject.objectWithURI("Set the URI of an existing KiiObject here");
    var targetObject = KiiObject.objectWithURI("Set the URI of an existing KiiObject here");
    var targetObjectUri = targetObject.objectURI();
    
    sourceObject.moveBody(targetObjectUri).then(
      function(params) {
        var theSrcObject = params[0];
        var theTgtObjectUri = params[1];
        // Do something.
      }
    ).catch(
      function(error) {
         var theSrcObject = error.target;
         var theTgtObjectUri = error.targetObjectUri;
         var errorString = error.message
        // Handle the error.
      }
    );