How do I manage Attachments (View / Delete) - xpages

I am able to add a file upload control to my page and add attachments. But how do I manage them? View , delete?
I added a computed field to my xpage and make the attachments field the source and set the field as HTML. I get a bunch of entries like (See attached file: abc.pdf). But that does not seem to do what I want.
Is there an easy way to manage these attached files?

Bind a file download control to the same data the upload control is bound to. One of the attributes this component supports is a boolean for whether to allow deletion. You can also choose which attributes of each file it displays (MIME type, size, etc.).

What is wrong with having an repeat control repeat over the filenames and generate links directly to those files where on the links there are event handlers which do a remove or view ?

Related

Lotus notes: create document preview

In LN 6.5.6 i have a view with a lot of type of documents(with different form and fields) and i want to create a preview mode of that document using:
dynamic form: User select a document and a script compose a form with all fields of that document and open it with DialogBox method. (i must have to create a new form because the database do not cointain any form, forms are in other databases)
OR
dynamic view: User select a document and a script compose a view with all fields of that document and open it.
Is this possible?
Sure, it's possible. Just have the script copy the document to a temporary NSF file that contains whatever forms or views you want, and then bring up the dialog from there. The problems, though, are that when the user exits the dialog they'll find themselves in the temporary database instead of where they expected to be, and you'll probably need a way to clean up the temporary database, too.
Or for the view idea, your script can create a temporary folder with the columns that you want, put the selected document in the folder, and then open the folder. Again, though, the problem is that the user will not really know where he is and how to get back where he was, and you'll have to figure out a way to clean up the temporary folders.
Why not instead just add a form to the database, make it the default form, and just give it all the fields it needs for your previews of the fields you want from documents of different types?

Read only appears like disable control in CRM

I am new to CRM, and I have run into a requirement where I have to show some controls (textbox, option set, etc) and custom entities (sub - grid) as readonly. But, when I made them readonly, they appears like disabled and are getting grayed out. Is there any way to make them only read only not look like disabled?
Please suggest.
Thanks,
Ashfaq.
in CRM read-only means fields are greyed out but still they are readable.
If you want to make the fields visible as normal but don't want them to be editable by the user, you need to write JavaScipt for that.
Take the following steps.
1. Make the fields editable.
2. On form's OnSave Event, call the following method to prevent the attributes to be saved.
function PreventSave()
{
Xrm.Page.getAttribute(“CRMFieldName”).setSubmitMode(“never”);
}
It will not grey out the fields and still prevent the user to change their values.
I hope it will help you.
For text fields, there is one type of text field that when set to readonly does not look like it is disabled. Off the top of my head I can't remember which type. For the other field types I have not found a way to not have them look disabled when made readonly.
Other option is not to use form fields but show the data you need to be readonly (and not grayed out) in a web resource (HTML/SL/etc). Be aware tho that if your users are using outlook with crm addin, there are limitations here when the record is viewed in the outlook reading pane.
Only other option I can think of is to not set the fields as readonly but control any field data changes with javascript.
In short, I haven't found a good way to do what you need.

Is there Java/SSJS equivalent of #AttachmentModifiedTimes?

I want to show list of attachments and FileDownload control is not an option (need custom actions for every file).
To get name and size of attachments there are properties of EmbeddedObject. AFAIK, to get modified time of attachment there is only one option: to use pure #Formula, either via session.evaluate or view containing column with #AttachmentModifiedTimes.
Is there a way (Java/SSJS) to get attachment's modified (and created) time without native #Formulas? That means date stored with file shown in document properties for $FILE item.
You can add a Repeat Control to the page and bind that to the attachments (stored in a rich text field) using document1.getAttachmentList("rt_field_name"). Every item in that list is an object of class
com.ibm.xsp.model.domino.wrapped.DominoDocument$AttachmentValueHolder
That class has a getLastModified() method that returns the last modified time as a Double.
A couldn't find a reference on the web showing the full API, but if you use the API Inspector in the XPage Debug Toolbar (sorry for the shameless plug...) you can view all properties and methods using:
getComponent( 'id_of_repeat_control' ).getDataModel().getRowData()
UPDATE
Found the API here,
I am not 100% sure what you want to achieve.
In general you can use #AttachmentModifiedTimes() - as well as #AttachmentNames() - as SSJS.

Programmatically Modify EditForm.aspx

I am working with document upload, after upload, it takes user to EditForm.aspx, where I do not want few of the fields displayed.
How do I hide Fields from EditForm.aspx programmatically? Including automated deployment.
You don't.
You simply update the list fields to set them as non editable via the ShowInEditForm property.
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spfield.showineditform.aspx

How to save a word template for a content type without filling in required fields

I have a content type that has required fields. I have associated Word document with the content type as a template. I now want to edit the Word template, but word won't allow me to save the template without filling in the required fields. However, if I fill in the required fields and save the document, then those fields get populated with my values when you create a new document. This isn't good because I want the fields to be blank when a new document is created - I want the users to be forced to fill in those values.
I can update the templace by updating the colums and making them optional, editing the word template, saving the template & then changing the columns back to required. This is a PITA - there's got to be a better way, does anyone know what it is?
I've been using this work around: When I edit the template (ie go to the content type settings --> Advanced settings --> Edit Template), I make my changes and save the file locally. Then, on the same page that I clicked the "Edit Template" link, I upload the copy that I saved locally. Saving it locally avoids the validation that happens when you try to save it back to SharePoint. But the validation still gets applied to any new documents of that content type. So no need to toggle the settings off & on! :)
Have you tried saving the document as a normal document content type, making the changes, saving it, then moving back over the top of where the old version of the template was?
The only solution I've found is to modify document templates on library level. Just upload a new document template for the required content type.
However, this will not work if you'd like to re-use one and same content type across different document libraries.

Resources