Failure creating document in Matter Centric HP/Autonomy WorkSite (iManage) DMS - imanage

I'm trying to create a document in the DMS, set some attributes, then check it in. This worked great until we disallowed flat-space filing. Now I have to specify a workspace folder before I can save, but I can't seem to figure out how to do so.
lcDoc = mcDatabase.CreateDocument()
lcDoc.Security.DefaultVisibility = imSecurityType.imView
lcDoc.Security.GroupACLs.Add("INFORMATION_TECHNOLOGY", imAccessRight.imRightAll)
lcDoc.Profile.SetAttributeByID(imProfileAttributeID.imProfileDescription, FileName)
lcDoc.Profile.SetAttributeByID(imProfileAttributeID.imProfileAuthor, msUserID)
lcDoc.Profile.SetAttributeByID(imProfileAttributeID.imProfileOperator, msUserID)
lcDoc.Profile.SetAttributeByID(imProfileAttributeID.imProfileType, "ANSI")
lcDoc.Profile.SetAttributeByID(imProfileAttributeID.imProfileClass, "ADMIN")
lcDoc.Profile.SetAttributeByID(imProfileAttributeID.imProfileCustom1, ClientID)
lcDoc.Profile.SetAttributeByID(imProfileAttributeID.imProfileCustom2, MatterID)
lcDoc.Profile.SetAttributeByID(imProfileAttributeID.imProfileCustom10, "060")
lcDoc.Profile.SetAttributeByID(imProfileAttributeID.imProfileCustom14, DMSServerName)
' Fails here with error: [Folder ][AddDocument ]Operation requested on a record that does not exist.
DirectCast(loFolder, NRTFolder).AddDocument(DirectCast(lcDoc, NRTDocument))
' If I comment out the line above, this line returns a failure:
' This operation is currently not available due to flatspace filing restrictions.
Dim lcResults As IManCheckinResult = lcDoc.CheckInWithResults(lsFilePath, imCheckinDisposition.imCheckinNewDocument, imCheckinOptions.imDontKeepCheckedOut)
I'm struggling to find the right API document that gives this answer.

OK, so the solution was on an interface I didn't know about, but found the COM developer's guide on page 81.
lcDoc = mcDatabase.CreateDocument()
'lcDoc.Profile.SetAttributeByID(imProfileAttributeID.imProfileLocation, loFolder.ObjectID)
lcDoc.Security.DefaultVisibility = imSecurityType.imView
lcDoc.Security.GroupACLs.Add("APPLICATIONSDEVELOPMENTALL", imAccessRight.imRightAll)
lcDoc.Security.GroupACLs.Add("INFORMATION_TECHNOLOGY", imAccessRight.imRightAll)
' [04/21/2014 KB] Changed this to use the specified name instead of a hard coded one.
' lcDoc.Profile.SetAttributeByID(imProfileAttributeID.imProfileDescription, String.Format("iManageAPI:{0}", "Test Create Document"))
lcDoc.Profile.SetAttributeByID(imProfileAttributeID.imProfileDescription, FileName)
lcDoc.Profile.SetAttributeByID(imProfileAttributeID.imProfileAuthor, msUserID)
lcDoc.Profile.SetAttributeByID(imProfileAttributeID.imProfileOperator, msUserID)
lcDoc.Profile.SetAttributeByID(imProfileAttributeID.imProfileType, "ANSI")
lcDoc.Profile.SetAttributeByID(imProfileAttributeID.imProfileClass, "ADMIN")
lcDoc.Profile.SetAttributeByID(imProfileAttributeID.imProfileCustom1, ClientID)
lcDoc.Profile.SetAttributeByID(imProfileAttributeID.imProfileCustom2, MatterID)
lcDoc.Profile.SetAttributeByID(imProfileAttributeID.imProfileCustom10, "060")
lcDoc.Profile.SetAttributeByID(imProfileAttributeID.imProfileCustom14, DMSServerName)
''loFolder.AddDocument(lcDoc) 'Add document to folder
'DirectCast(loFolder, NRTFolder).AddDocument(DirectCast(lcDoc, NRTDocument))
'Dim lcResults As IManCheckinResult = lcDoc.CheckInWithResults(lsFilePath, imCheckinDisposition.imCheckinNewDocument, imCheckinOptions.imDontKeepCheckedOut)
lcResults = DirectCast(lcDoc, IManDocument3).
CheckInExToFolderAsNewDocumentWithResults(lsFilePath, imCheckinOptions.imDontKeepCheckedOut, loFolder,
imHistEvent.imHistoryNew,
System.Reflection.Assembly.GetExecutingAssembly().FullName,
"", "")

Related

How to create a folder with % character on SharePoint 2019 using rest calls via postman?

I want to create a folder with % character on SharePoint 2019 and I am using the below call:
POST http://<site>/_api/web/folders
{
"__metadata": {
"type": "SP.Folder"
},
"ServerRelativeUrl": "/SP 2019/Folder%"
}
But this is creating a Folder%25 instead of Folder%.
If I change the character in the JSON to #, it creates a folder with '#' character.
This does the job.
POST http://<site>/_api/web/folders/AddUsingPath(decodedurl='Path')
It will create a folder with % character. It was introduced for SP Online but also works with SP 2019.
The issue i am running into is the api returns 400 Bad Request in two cases:
a) The folder already exists.
b) The URL is malformed.
I need to distinguish between the two.
You may take a look at this Microsoft's page for further refrence.
The value we passed in was ‘%’, but it seems that the server escaped it.
As a workaround ,you could create a event receiver(item added) . When a folder is created, if its name contains ‘%25’, rename it.
Sample code:
public override void ItemAdded(SPItemEventProperties properties)
{
SPFolder folder = properties.ListItem.Folder;
string name= folder.Name;
if (name.Contains("%25")) {
string newName=name.Replace("%25", "%");
folder.Item["Name"] = newName;
folder.ParentWeb.AllowUnsafeUpdates = true;
folder.Item.Update();
folder.ParentWeb.AllowUnsafeUpdates = false;
}
base.ItemAdded(properties);
}
Best regards,
Amos

Github - How to search a gist via API?

I understand that it is possible to search a repository via various criteria with the Github API but how to search for a single gist or find its id?
Ideally I'd like to use user and filename but it could be a hash inside the content body:
https://gist.github.com/search?q=sadjghasghdhjasgdfhs
I just found out that it is possible to search for a specific user and/or filename. I've looked at the advanced search of github, which uses user:some-user-name and path:some-file-name. These criteria also work on the gist search terms.
example: https://gist.github.com/search?q=user%3Amanuelvanrijn+path%3Aguid.js
Hope this helps until there's a search api available for gists
The GitHub community post given in as comment as the top answer no longer works. I pulled the Ruby example from archive.org, here it is:
module GistSearch
class << self
def search_public_gists(query:, page_limit: 10)
docs = []
base_url = "https://gist.github.com"
next_path = "/search?q=#{query}"
page_limit.times do
url = "#{base_url}#{next_path}"
html = fetch_cached(url)
doc = Nokogiri(html)
docs << doc
if !doc.search("a[rel=next]").empty?
next_path = doc.search("a[rel=next]").attr("href").value
else
break
end
end
docs
end
def build_items(queries:)
queries.flat_map do |query|
search_public_gists(query: query).flat_map do |doc|
doc.
search(".gist-snippet").
map do |gist_snippet|
Item.new(
creator: gist_snippet.search(".creator a:first").text,
title: gist_snippet.search(".creator a").map(&:text).join(" / ") + " (Matched query: #{query.inspect})",
link: gist_snippet.search(".link-overlay").attr("href").value,
guid: gist_snippet.search(".link-overlay").attr("href").value,
pub_date: Time.iso8601(gist_snippet.search("time-ago").attr("datetime").value),
content: gist_snippet.search(".js-file-line").map(&:text).join("\n"),
)
end
end
end
end

Annot doesnt have action

I'm trying to change all annotations link destination to fit page and also i need to validate the links.
This is the code i'm trying
Dim PdfReader As PdfReader
'Dim myBookmarks As New List(Of Dictionary(Of String, Object))()
Dim pg As Integer
PdfReader = New PdfReader("D:\\Annot_Testing.pdf")
Dim PageCount As Integer = PdfReader.NumberOfPages
For pg = 1 To PdfReader.NumberOfPages
Dim PageDictionary As PdfDictionary = PdfReader.GetPageN(pg)
Dim Annots As PdfArray = PageDictionary.GetAsArray(PdfName.ANNOTS)
If (Annots Is Nothing) OrElse (Annots.Length = 0) Then
Continue For
End If
''//Loop through each annotation
For Each A In Annots.ArrayList
''//I do not completely understand this but I think this turns an Indirect Reference into an actual object, but I could be wrong
''//Anyway, convert the itext-specific object as a generic PDF object
Dim AnnotationDictionary = DirectCast(PdfReader.GetPdfObject(A), PdfDictionary)
''//Make sure this annotation has a link
If Not AnnotationDictionary.Get(PdfName.SUBTYPE).Equals(PdfName.LINK) Then Continue For
''//Make sure this annotation has an ACTION
If AnnotationDictionary.Get(PdfName.ACTION) Is Nothing Then Continue For
''//Get the ACTION for the current annotation
Dim AnnotationAction = DirectCast(AnnotationDictionary.Get(PdfName.A), PdfDictionary)
''//Test if it is a named actions such as /FIRST, /LAST, etc
If AnnotationAction.Get(PdfName.S).Equals(PdfName.NAMED) Then
MsgBox("Yes named")
''//Otherwise see if its a GOTO page action
ElseIf AnnotationAction.Get(PdfName.S).Equals(PdfName.PAGE) Then
MsgBox("page")
ElseIf AnnotationAction.Get(PdfName.S).Equals(PdfName.GOTOR) Then
MsgBox("gotoR")
ElseIf AnnotationAction.Get(PdfName.S).Equals(PdfName.GOTO) Then
''//Make sure that it has a destination
If AnnotationAction.GetAsArray(PdfName.D) Is Nothing Then Continue For
Dim AnnotationReferencedPage = PdfReader.GetPdfObject(DirectCast(AnnotationAction.GetAsArray(PdfName.D).ArrayList(0), PRIndirectReference))
''//Re-loop through all of the pages in the main document comparing them to this page
For J = 1 To PageCount
If AnnotationReferencedPage.Equals(PdfReader.GetPageN(J)) Then
Trace.WriteLine(J)
Exit For
End If
Next
ElseIf AnnotationAction.Get(PdfName.S).Equals(PdfName.URI) Then
Else
MsgBox("else type")
End If
Next
Next
'bookmarkGlobalSetting(myBookmarks)
PdfReader.Close()
In the sample document attached having 3 annots, but its not showing action on it while reading via code, but its availed when seeing this in acrobat. Please suggest me on this..
please download from here... https://drive.google.com/file/d/0B72uT6TzR_cdWGczRkY3ZmNpeTg/edit?usp=sharing
Those annotations do not have any A action entry:
Your expectation to find an action with a link is wrong because it may alternatively have a destination, cf. section 12.5.6.5 Link Annotations of ISO 32000-1:
A link annotation represents either a hypertext link to a destination elsewhere in the document (see 12.3.2, “Destinations”) or an action to be performed (12.6, “Actions”). Table 173 shows the annotation dictionary entries specific to this type of annotation.
Your code only deals with the latter type (with an action to be performed) and not the former (with a hypertext link to a destination elsewhere in the document).
Thus, you have to improve your code to also deal with the former type. You'll find details in Table 173 – Additional entries specific to a link annotation of ISO 32000-1.
PS: I assume your
If AnnotationDictionary.Get(PdfName.ACTION) Is Nothing Then Continue For
should have been
If AnnotationDictionary.Get(PdfName.A) Is Nothing Then Continue For

How to obtain the image path/ url from a file uploaded on an openshift data dir to be stored in a postgresql database?

I am a self-taught programming newbie here so please bear with me. I am trying to create a site which allows users to upload their images on. With the patience of another user, I was able to get some answers as to how to create and allow users to upload their images onto the data drive on openshift. However, now I need to be able to store the image path or url onto a postgresql database (which can be called on later) so that each user will be able to keep track of the images that they have uploaded. I am currently stymied by this.
Here are the fragments of code which I feel plays a big role in answering this question:
class Todo(db.Model):
__tablename__ = 'todos'
id = db.Column('todo_id', db.Integer, primary_key=True)
title = db.Column(db.String(60))
text = db.Column(db.String)
done = db.Column(db.Boolean)
pub_date = db.Column(db.DateTime)
user_id = db.Column(db.Integer, db.ForeignKey('users.user_id'))
image_url = db.Column(db.String)
def __init__(self, title, text, image_url):
self.title = title
self.text = text
self.image_url = image_url
self.done = False
self.pub_date = datetime.utcnow()
def allowed_file(filename):
return '.' in filename and \
filename.rsplit('.', 1)[1] in app.config['ALLOWED_EXTENSIONS']
#app.route('/upload', methods=['POST'])
def upload():
# Get the name of the uploaded file
file = request.files['file']
# Check if the file is one of the allowed types/extensions
if file and allowed_file(file.filename):
# Make the filename safe, remove unsupported chars
filename = secure_filename(file.filename)
# Move the file form the temporal folder to
# the upload folder we setup
file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
# Redirect the user to the uploaded_file route, which
# will basicaly show on the browser the uploaded file
return redirect(url_for('uploaded_file',
filename=filename))
#app.route('/uploads/<filename>')
def uploaded_file(filename):
return send_from_directory(app.config['UPLOAD_FOLDER'],
filename)
#app.route('/new', methods=['GET', 'POST'])
#login_required
def new():
if request.method == 'POST':
if not request.form['title']:
flash('Title is required', 'error')
elif not request.form['text']:
flash('Text is required', 'error')
else:
todo = Todo(request.form['title'], request.form['text'])
todo.user = g.user
db.session.add(todo)
db.session.commit()
flash('Todo item was successfully created')
return redirect(url_for('index'))
return render_template('new.html')
The current code that I have is pieced together by various tutorials and examples.
Currently, I am trying to merge the "Todo" db, "upload" function and "new" function and am having very little success. Using the little knowledge I have, I have merely added the "image_url" portions in which will be a column that is intended to house the image path. I would greatly appreciate it if somebody could shed some light on this conundrum. Thanks a million.
Respectfully,
Max

Trying to Insert QBO Credit Memo with IPP.NET

I am using IPP.Net to attempt to insert a single CreditMemo into Quickbooks Online. I have been successful inserting an invoice with similar code. My code for inserting the CreditMemo is as follows:
Try
Dim qboCreditMemo As New Intuit.Ipp.Data.Qbo.CreditMemo
Dim qboCreditMemoHdr As New Intuit.Ipp.Data.Qbo.CreditMemoHeader
Dim qboCreditMemoLine As Intuit.Ipp.Data.Qbo.CreditMemoLine
Dim CreditMemoLines As New List(Of Intuit.Ipp.Data.Qbo.CreditMemoLine)
Dim CreditMemoItemAttributes As Qbo.ItemChoiceType2()
Dim CreditMemoItemValues As Object()
For Each row In tblTrans.Rows
If bFirstRow Then
'Set CreditMemo header
qboCreditMemoHdr.DocNumber = "SMA" & CStr(row("batch_id"))
qboCreditMemoHdr.TxnDate = Format(row("acct_date"), "yyyy-MM-dd")
qboCreditMemoHdr.Msg = row("batch_descr")
qboCreditMemoHdr.CustomerId = New Intuit.Ipp.Data.Qbo.IdType
qboCreditMemoHdr.CustomerId.Value = row("iface_owner_id")
qboCreditMemo.Header = qboCreditMemoHdr
bFirstRow = False 'only do this once
End If
'Lines
qboCreditMemoLine = New Qbo.CreditMemoLine
qboCreditMemoLine.Desc = row("descr")
qboCreditMemoLine.Amount = row("amount_owner")
qboCreditMemoLine.AmountSpecified = True
CreditMemoItemAttributes = {Qbo.ItemsChoiceType2.ItemId, Qbo.ItemsChoiceType2.UnitPrice, Qbo.ItemsChoiceType2.Qty}
CreditMemoItemValues = {New Qbo.IdType With {.idDomain = Qbo.idDomainEnum.QBO, .Value = row("iface_item_id")}, row("unitPrice"), row("quantity")}
qboCreditMemoLine.ItemsElementName = CreditMemoItemAttributes
qboCreditMemoLine.Items = CreditMemoItemValues
qboCreditMemoLine.ClassId = New Intuit.Ipp.Data.Qbo.IdType
qboCreditMemoLine.ClassId.Value = row("iface_class_id")
CreditMemoLines.Add(qboCreditMemoLine) 'Add line to list of lines
Next row
qboCreditMemo.Line = CreditMemoLines.ToArray 'Add CreditMemo lines to CreditMemo lines property
resultCreditMemo = commonService.Add(qboCreditMemo) 'Add CreditMemo to request
Return "OK"
'Catch exID As Intuit.Ipp.Exception.IdsException
'Return exID.Message
Catch ex As Exception
Return ex.Message
End Try
I got an error with message 'Internal Server Error'. It seems to be an IdsException. As indicated in my other article, I was able to get detailed information for a BatchRequest through the Fault and Error objects. However, I do not understand how to get the details on this error for a single invoice using Dataservices.
I think I may need better error handling, assuming there is more information available for this error. And, I need help figuring out why the same properties that I set for an invoice would not work for a CreditMemo. Unfortunately the documentation in the Intuit website where the required properties are listed does not include a CreditMemo (though it includes an Invoice).
CreditMemo is not supported in QBO:
https://ipp.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/0400_QuickBooks_Online/0500_Supported_Entities_and_Operations
I had almost the same issue, and the problem was that the qty and amount should not be negative. I changed it on my creditmemoLine and it worked