Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
im noticing weird behaviour using few api methods. The idea is to delete measure from specific document and then recreate if.
Here is the workflow im following:
* Using the Engine API Explorer im invoking the GetMeasure method and copy the string for the returned generic object. ( Im using the Executive Dashboard so you can check with measure id = bUft)
* DeleteMeasure - with id bUft
* CreateMeasure - pasting the generic object from step 1
* at this point im expecting to have exactly the same measure and the api returns almost exactly the same object. The only difference is that the new "imported" measure have a different id. For example "95ddc165-9a5d-42a4-a1cb-337e36511fd4" instead "bUft"
* try GetMeasure again with id = bUft - the api returns null
After this im trying:
* invoke DoSave() method
* refresh the page with the api explorer
* check the GetMeasure again - still null
* try CreateMeasure again
* the measure is created with the correct id (bUft)
Interesting bit is that this is happening with Measures, Dimensions and MasterObjects. For the other objects ( like sheets, snapshots etc.) this is not the case. Deleting the object and recreating it right after this (without invoking DoSave or SaveObjects methods) is creating exactly the same objects.
Am I missing something?
Thanks!
Stefan
Desktop or Server?
You can't have multiple objects with the same IDs in a QVF so when you delete the object and then right after try to create a object with the same ID most likely the ID has not been free'd up yet.
If you are on Desktop I would suggest you call a DoSave to persist the ID changes and free up available ones.
Desktop (for now)
I've tried with DoSave() as well but result was the same.
Will try with the server today as well.
I thought that the callback of the delete method is returned after the object is completely removed (free the id as well)?
Any idea if i wait few seconds before start creating the object will be an workaround?
I've managed to get 2 workflows (in QS Desktop) - working and not working (below is paste from Chrome console log)
Not working:
Open doc --> Doc "Executive Dashboard.qvf" is open
Get all measures --> Available measures: 1 ["NPPsJt"]
Delete all measures --> Measure ID: NPPsJt was deleted; 1 measures was deleted
doSave() --> Saved
Get all measures --> Available measures: 0; []
Create 1 measure --> Measure: "Revenue" (NPPsJt) was created
Get all measures --> Available measures: 1; ["8d45835a-488d-4ae8-bf3b-6868ad8c1adf"]
doSave() --> Saved
Delete all measures --> Measure ID: 8d45835a-488d-4ae8-bf3b-6868ad8c1adf was deleted; 1 measures was deleted
doSave() --> Saved
Get all measures --> Available measures: 0; []
Create 1 measure --> Create 1 measure --> Measure: "Revenue" (NPPsJt) was created
Get all measures --> Available measures: 1; ["42e7e45c-2a09-4629-9306-f3770a5218b8"]
doSave() --> Saved
Working:
Open doc --> Doc "Executive Dashboard.qvf" is open
Get all measures --> Available measures: 1 ["NPPsJt"]
Delete all measures --> Measure ID: NPPsJt was deleted; 1 measures was deleted
doSave() --> Saved
Get all measures --> Available measures: 0; []
--------------------------------> At this point I'm refreshing (F5) the app in the QS Deskop and also refresh the mashup page
Open doc --> Doc "Executive Dashboard.qvf" is open
Get all measures --> Available measures: 0; []
Create 1 measure --> Measure: "Revenue" (NPPsJt) was created
Get all measures --> Available measures: 1; ["NPPsJt"]
doSave() --> Saved
Attached are the hml and js file im using for this mashup
The same script but for Masterobjects, for example, works without any issue:
Open doc --> Doc "Executive Dashboard.qvf" is open
Get all Masterobjects --> Available Masterobjects: 1; ["tmaqpf"]
Delete all masterobjects --> Masterobject ID: tmaqpf was deleted; 1 Masterobject was deleted
Get all Masterobjects --> Available masterobject: 0; []
Create 1 Masterobject --> Masterobject: "Revenue by Product" (tmaqpf) with 0 children(s) was created
Get all Masterobjects --> Available masterobject: 1; ["tmaqpf"]
doSave() --> Saved
Perhaps this is beside the point, but why are you deleting and recreating measures? Wouldn't it be easier to modify them?
Erik
Im using SerializeApp (mindspank/serializeapp · GitHub) to create a "backup" of QS app.
And my idea is to have a script that can recreate all the objects from this json file.
But to be more correct i want to drop all the objects from the app first and then create the ones from the json file.
One problem is that if you try to create an object with an ID that Sense Engine thinks already exists, the engine will simply assign another ID. You should get the ID in the reply, documentation here.
Since you are recreating an app this is bad news: visualizations using the measure will probably refer to it by the old id. It would probably be safer to check if the measure already exists, and in that case modify it.
Erik
Yes this is the case. But think that something somewhere is wrong. Because I don't have this issue with other object types (masterobjects, sheets etc) following the same workflow.
With other object types I can delete and then create the object and the result is new object with the correct id (not self generated one). With dimensions im deleting the object, check if it exists and the engine return false, create the dimension and the id is new (seems that the object still exists) which for me is not normal.
Since I don't know what is modified I need to compare the old and the new object and then update only the different properties which applied to all object types might be pretty tricky task. For this reason I went with "delete-create" approach.
I'm kinda convinced myself that this is due to some issue with the API or for this object types different workflow need to be followed.
Stefan
This might be a bug, though probably in the engine itself rather than in the API's. Please report it.
Erik