Revit API - How to check for open Transactions, Sub-transactions, or Group Transactions - revit-api

I'm working on a button where I have a project document open and a family document open. I'm trying to close the family document however I'm getting an error saying:
Autodesk.Revit.Exceptions.InvalidOperationException: 'Close is not allowed when there is any open sub-transaction, transaction, or transaction group.'
I've checked all of my transactions and they are all started and committed using transactionName.Start(document) and transactionName.Commit()
does anyone know of a way to check for any ongoing active transactions?
I have also tried using
'RevitCommandId closeDoc = RevitCommandId.LookupPostableCommandId(PostableCommand.Close);
uiapp.PostCommand(closeDoc);'
however that tends to only want to close my project document.
///////////////////////////////////UPDATE/////////////////////////////
soooo I just found out I didn't need to use uiapp.OpenAndActivateDocument(). I didn't know you could edit a family without opening the document. That solves my problem. I'm still curious if there's a way to check for open transactions though.

Yes there is a way to check for open Transactions and its quite helpful in making flexible helper-functions. The Document object has an IsModifiable property - essentially if a Transaction is open, then this will be True.
I use it like this:
autoTransaction = False
if not document.IsModifiable:
t = Transaction(document, 'New Transaction cause no transaction was open')
t.Start()
autoTransaction = True
# go ahead and modify the database
if autoTransaction:
t.Commit()
Its served me well so far, hope this helps!

Afaik, the Revit API does not enable you to check from outside whether a transaction is started. You need access to the Transaction object itself to check its status. If you did not create it yourself, you have no access to it.
How did you open the two documents?
What Revit commands did you execute in them?

Related

how to delete workorders in maximo

In maximo, can we delete a work order? The select action menu gives me
BMXAA4612E - Cannot delete because it is, or had at one time been approved.
I have created numerous test work orders and it is getting difficult to track new work orders.
Short Answer: You can't.
Standard Maximo will not let you delete it past a certain point. It keeps this data around for a sort of auditing (and because there could be a lot of dependencies to undo).
Bad Answer: With some database queries. You can of course delete about anything if you start modifying Maximo's underlying database directly. The Work Order object has a number of related tables though, so make sure you delete all referenced data from those as well. And there might be other places you need to update too, like a PM due date, depending on the situation.
In a normal Maximo environment, it is very common to have a lot of open work orders at any given time. You are going to need to develop ways to handle the fluff. Closing your old test work orders helps, because Maximo filters out closed work orders by default. Standard filters with some specialized data and saved queries are some other options.
Clear attribute: FIRSTAPPRSTATUS
update woactivity set FIRSTAPPRSTATUS = null
where ;
Then deleting should be possible
--> However it is not (in maximo 7.6)
For Maximo 7.6, change the workorder status to WAPPR from the backend or through MIF and then use MIF to delete the record(s)
I created an action that executes set FIRSAPPRSTATUS null and created an escalation with the condition of selecting a work order. After the escalation is completed, deletion will be available if the remaining conditions for deleting the work order are met.

How to prevent Lotus Notes from saving a document created by a DXL Import?

I followed this link enabling me to setup a hotspot in a richtext field - works like charm.
http://ozinisle.blogspot.de/2010/11/lotusscript-code-to-append-hotspot-to.html
Only problem is, as the user(s) usually do(es) not have deletion rights, the document created by the import stays stored in the database. In LotusScript e.g. I can create a new temporary document and work with it, and if I'm not saving it, it just disappears at the end of the function.
Is there a similar way or parameter for DXL import which allows me to just drop the document after I got my rtitem?
Alternatively, can someone point out to me if it is possible to create only the temporary richtext item in/on a document I created as tempdoc via LotusScript?
My search on the web did not get any results and my tries to reduce the linked function always resulted in the error 4518 (which is described in the help document of "DXLImporter"); if I read the help right, the DXLImporter only supports the db as valid output (thus expecting documents being created via DXL).
I don't see a way to import DXL without creating a document.
The easiest solution is to create the temporary document in users "cache.ndk". The user has definitely the right to delete documents there. So, you'd replace the line "Set db = session.CurrentDatabase" in code you linked to with
Set db = session.Getdatabase("", "cache.ndk", false)
The rest of the code would stay the same.
As an alternative, use the more classic approach running an agent on server to delete the temporary document. Create an agent which deletes the document, set property "Run on behalf of" to someone who is allowed to delete documents in database and call the agent from your script with
agent.RunOnServer(noteID)

I Need to prevent saved conflict in xpage

Scenario :- I opened the same document in different browsers(users). One user modified and saved the document. another user also modifying the same document which creates saved conflicts. for this I googled and found the link and tried.
http://dontpanic82.blogspot.in/2010/01/xpages-custom-control-that-can-help.html
(Thanks to Mr Tommy).
I included this custom control in another custom control(Form) at the end of Cc.
I am getting currentDocument not found in before render response event. I have my data source name document which is defined for full page not for panel.
Document handle is not getting in Before render response event?
Please help to me to solve this. or is there any other way to prevent saved conflicts?
Have a look at the concurrencyMode property of the document datasource.
You can for instance set it to fail in order for the document save to stop (fail) if a save conflict occurs. If you have (or add) a message control to your xpage, a save conflict error message will then appear.
If you isn't building for XPinc you could use my Document locker project on openntf.org
Document Locker on openntf.org
It works like this, when a user opens a document a< lock is added to an application scope bean. And when the user exits the document this lock is removed. if another user tried to enter the document at the same time they will be redirected to readmode.
Also, check the section in Mastering XPages 2nd Edition about document locking. That gives thorough examples for enabling the in-built Domino document locking.

Adding logging in Lotus Notes form

I want to add logging capabilities in my Lotus Notes application. Basically I want to be able to log who make the change, when the change is made, and what field(s) is/are changed in a document. What is the best way to do this? I am thinking to also add this at the end of each document so the user knows who make the changes.
OpenNTF has several tools for this purpose that you could use, including Open Audit and Audit Manager.
I've done this before using LotusScript. It's a bit of a pain, but the basic idea is to:
Create an array or new document object within the QueryOpen event, and store the values for all the items in the current document.
In your QuerySave event, compare the values of the current document to the in-memory copy you made, and then log any differences.
You can create a field on the form to write these changes to, and just append to it each time.
Watch out for other event handlers that make changes everytime the document opens, though. You may need to copy original values in the PostOpen event, for example, if you change some fields in the QueryOpen event each time the doc opens, otherwise you'd get false change logs.
Hope this helps!
A "brute force" approach can also work. Every time a document is saved, create a copy of that version to a (separate) database. This will build an audit trail of the documents. The documents can be compared to extract the changes.
There is quite some overhead in this approach, but in my experience it has been worth it. The implementation is simple and all changes are captured without affecting the actual document. All information that is needed is captured and available for (offline) processing.

Disable Word/Sharepoint Integration

I have a requirement to disable the integration between Sharepoint and Word in a project that I am working on. This requirement comes from the request that the user is able to edit the properties of the document but not edit the document itself. The request has also been made to disable the Shared Workspace toolbar that appears when a document is open. The solution must exist on the server as some of the users are external. The users have also requested that they are able to use the Outlook/Sharepoint Integration. Does anyone have any thoughts on how this can be accomplished?
I'm guessing they want to change some document properties, apply those as new field values and print - but not change the original.
Here are some ideas, not sure how useful they could be.
1) apply a password for editing the Word document - It may still allow changing properties & printing.
2) strip out doc the properties and put them in a sharepoint list, with the document itself as an attachement - the document then remains as read-only, but the properties are held separately
3) If your documents are in a list, Allow changes on the list, but demand changes be approved, so users only get to see their own changes, no-one else sees the changes they made. Changes will sit there pending approval. Periodically you can go and reject any changes.

Resources