Hi Everyone
This should presumably be pretty simple.
I've made some changes to a model as part of producing a printed report. Those changes are purely cosmetic so I'd like to discard the changes at various stages of my script execution.
I've set
ArisData.Save(Constants.SAVE_ONDEMAND);
so that changes aren't automatically saved, but how do actually I tell the engine to discard them?
Thanks
Dan
Hi Dan,
If you use SAVE_ONDEMAND mode, you won't get for example up-to-date model image or other information from database. All the changes you've done during report's working are in memory (in queue). So you have to save changes and then get up-to-date information from db.
I suppose there are two ways to change something, output it and discard changes:
1. Change something in db in normal save mode and do opposite operations to discard changes. Cons is that you will be saved as user who changed model.
2. Create temp model (copy of source) change it, output and delete. Cons is processor and memory load if your source data is big number of models.
BR, Nikita
Hi Dan,
I've decided to check everything that I supposed and found out that I've made mistake. I was wrong, I'm sorry.
Everything is much more easy.
If you use SAVE_ONDEMAND mode, you can change everything and get changed information during report's working. Even images of models will contain all the attributes (names, for example) you change in session of report.
And all the changes you've done in this mode won't get to database. So you can use modified information only in session of report. And you don't need to discard any changes in this mode.
BR, Nikita
Hi Nikita,
it was very nice of you to look into it further.
I need to be a bit more precise with my requirements. I want to modify a model in memory during script execution, and add an image of the modified model to my report. Then discard those first changes, make a second lot of changes, and add the second image to my report also. Then the script execution finishes and the model returns to its pristine state.
Its the discarding of the first lot of changes that I’d like to accomplish.
Cheers
Dan
Hi Dan,
Nevertheless it works.
Here is piece of code.
ArisData.Save(Constants.SAVE_ONDEMAND); var db = ArisData.getActiveDatabase() var model = ArisData.getSelectedModels()[0] var loc = Context.getSelectedLanguage() var oOutput = Context.createOutputObject() model.Attribute(Constants.AT_NAME,loc).setValue("ModelName") model.ObjOccList()[0].ObjDef().Attribute(Constants.AT_NAME,loc).setValue("ObjectName") //model.ObjOccList()[0].ObjDef().Attribute(Constants.AT_NAME,loc).getValue() oOutput.BeginSection(297, 210, 12, 12, 25, 15, 20, 20, false, Constants.SECTION_DEFAULT) //output changed model oOutput.OutGraphic(model.Graphic(false,false,loc), -1, oOutput.getCurrentMaxWidth(), oOutput.GetPageHeight() - oOutput.GetTopMargin() - oOutput.GetBottomMargin() -32); db.refreshObjects(null,false)//refresh all the objects //output model without any changes oOutput.OutGraphic(model.Graphic(false,false,loc), -1, oOutput.getCurrentMaxWidth(), oOutput.GetPageHeight() - oOutput.GetTopMargin() - oOutput.GetBottomMargin() -32); oOutput.EndSection() oOutput.WriteReport()
Can I ask what ARIS version you're running? I'm on 10.0.0.2.
Your code throws the following error in my environment
-------------------
Exception in file, line 0:
An error occurred in the report object model, error running Database.refreshObjectsf) failed.
-------------------
I came across this last night with my script code. My ARIS version won't accept null as the first parameter to the refreshObjects call and so throws that error. Instead, you have to supply an ArisObject[] array.
So I called refreshObjects() twice; once with an array of models and a second time with an array of objOccs. In both cases, the report is produced without undoing the attribute change. See attached. I get the same results in my code.
The fact that refreshObjects() throws the error with null probably means it's not the only gremlin in the API call and that's why I'm not getting the refreshed view of the model.
But thanks so much for your help on this. It's really appreciated.