Check if object committed from client side

0
Hi everyone, From client side, we can retrieve an object by using Xpath. Suppose that we already have this MxObject. We are wondering if is there anyway to check if that MxObject is already committed to database or not ? Is this possible to use method "isNew" of MxObject to check that (there is no official documentation on this method)?   Best regars
asked
4 answers
3

if you have an object in a microflow you can use isnew to check if it has been committed. The object should be gotten over association to get uncommited objects from memory. 

Edit:

To dive a bit deeper, if we look at the mx.data.isNew function, we find that it refers to: 

i.prototype.isNew = function(t) {
       return this.has(t) && Boolean(this._newGuids[t])
}

Where according to my little research the _newGuids is a list that contains the new guids of objects that are created and it gets deleted on commit: 

i.prototype.onCommit = function(t) {
            var e = this;
            t.forEach(function(t) {
                return delete e._newGuids[t]
            })

So, in javascript you can use isNew to check for uncommited objects, just to be on the save side you could test it with a small widget, as my research was very limited

answered
1

Hi,

Retrieve by XPath will always only return objects that are already commited to the database.

-Andrej

answered
1

"isNew" won't do what you are looking for. It only returns true if the object was created in the same Microflow and not committed yet. To my knowledge there isn't a function yet built to "guarantee" the object you are working with in memory has already been committed. You will likely need to create a JS test or another microflow to compare GUID's and changeDate as a means to test, but that adds a bit of overhead you may not want. Without knowing the use case I can't say whether or not I would recommend running this kind of test vs. letting the modeler due the determination automatically for you.

answered
0

"isNew" actually works well on my case. 

- Create new MxObject by javascript

- Subscribe for changes of the object

- Call microflow to refresh the object

=>The callback of the subscription is fired and then the object will be retrieved by an Xpath.

And then i could use "isNew" to check if the object is committed or not.

I don't know is there any case the function is not usable?

Best regards,

answered