-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRelease Documents Locked by System.py
More file actions
73 lines (69 loc) · 2.54 KB
/
Release Documents Locked by System.py
File metadata and controls
73 lines (69 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# Release Documents locked by the system for the following modules
# Document Control
# Complaint
# Complaint Investigation
# MDR
# Change the affectedType and affectedNumber values in this section to unlock a specific document
#affectedType = "Document Control"
affectedType = "Complaint"
affectedNumber = "1245653"
from com.etq.util import Log
#------------------------------------------
def log(obj): #log to the engine log
obj = prepObjectForLogging(obj)
Log.info("\n", "\n~"+(thisDocument.getEncodedFieldText("ETQ$NUMBER"))+":"+thisUser.getName()+"~"+unicode(obj))
#------------------------------------------
def prepObjectForLogging(obj):# to make debugging easier and to avoid the null pointer exception
if obj==None:
obj="None" #else
if obj=="":
obj="empty string"
return obj
#------------------------------------------
try:
#Determine the correct application and document to construct query
if affectedType == "Complaint":
affectedApplication = "COMPLAINTS"
affectedObject = "COMPLAINT_DOCUMENT"
affectedDocNum = "COMPLAINT_DOCUMENT_ID"
affectedDesignName = "COMPLAINTS_COMPLAINT_DOCUMENT"
log("ok.Complaint")
elif affectedType == "Document Control":
affectedApplication = "DOCWORK"
affectedObject = "DOCWORK_DOCUMENT"
affectedDocNum = "DOCWORK_ID"
affectedDesignName = "DOCWORK_DOCUMENT"
log("ok.Document")
elif affectedType == "Complaint Investigation":
affectedApplication = "COMPLAINTS"
affectedObject = "INVESTIGAT_SUMMARY"
affectedDocNum = "INVESTIGAT_SUMMARY_ID"
affectedDesignName = "COMPLAINTS_INVESTIGATION_SUMMARY"
log("ok.Investigation")
elif affectedType == "MDR":
affectedApplication = "COMPLAINTS"
affectedObject = "MDR_DECISION_TREE"
affectedDocNum = "MDR_DECISION_TREE_ID"
affectedDesignName = "E_MDR_EVALUATION"
log("ok.MDR")
elif affectedType == "Return":
affectedApplication = "COMPLAINTS"
affectedObject = "RETURN_1"
affectedDocNum = "RETURN_1_ID"
affectedDesignName = "RETURN_1_P"
log("ok.Return")
except:
log("except")
pass
#construct query
affectedApp = thisUser.getApplication(affectedApplication)
query = "SELECT " + affectedObject + "." + affectedDocNum + " FROM " + affectedApplication + "." + affectedObject + " WHERE " + affectedObject + "." + "ETQ$NUMBER = " + "'" + affectedNumber + "'"
log(query)
#break lock on document
objectDocKeys = affectedApp.getDocumentKeysByQuery(affectedDesignName,query)
if (objectDocKeys != []):
for objectDocKey in objectDocKeys:
form = affectedApp.getDocumentInEditMode(objectDocKey)
if form != None:
form.save()
form.close()