Category Archives: Uncategorized

Changed outgoing mailserver on SPJSBlog.com

Hi,
I have had some trouble with messages disappearing – especially when someone answers a post in the forum. I have therefore change the outgoing email settings to use Postman SMTP plugin.

This means outgoing email will now be sent from my email address [@gmail.com] and not from [@spjsblog.com].

I’l monitor the email setup to ensure it works as expected, but please post any comments below.

Alexander

Log to a list when a document has been opened

This code used JSLink / Client side rendering and will therefore only work in SharePoint 2013.

What does this solution do?

This code  adds a custom link to open a document in the browser. Before opening the document the code writes the document name to a list to track that the current user has clicked the link.

This is a basic example, and you can use it as a starting point for your custom solution.

Setup

The code

Start by adding this code to a file in the site where you plan to use the code:

/*
JSLink code to log when a Document has been opened.
--------------------------
Author: Alexander Bautz / SPJSBlog.com
*/

var spjs_currDocInfo = {};

function spjs_logLinkClick(ctx){
var a, b = "", c = "";
a = ctx.CurrentItem;
spjs_currDocInfo[a.ID] = a;
c = a.FileLeafRef.substring(a.FileLeafRef.lastIndexOf(".")+1);
b = "<a class="ms-listlink" title="Open document and log to a list that you have opened this document.">"+"<img style="height: 16px; width: 16px; border: 0; vertical-align: top; margin-right: 3px;" src="/_layouts/15/images/ic"+c+".png" alt="" />"+a.FileLeafRef+"</a>";
return b;
}

function openDocAndLog(id){
var cc = new SP.ClientContext.get_current(), list = cc.get_web().get_lists().getByTitle('DocumentsOpenedLog'), nItem = list.addItem(new SP.ListItemCreationInformation());
nItem.set_item('Title', spjs_currDocInfo[id].FileLeafRef);
nItem.update();
cc.load(nItem);
cc.executeQueryAsync(
function(sender, args) {
SP.UI.ModalDialog.commonModalDialogOpen(_spPageContextInfo.webAbsoluteUrl+"/_layouts/15/WopiFrame.aspx?sourcedoc="+spjs_currDocInfo[id].UniqueId+"&action=interactivepreview",{"allowMaximize":true,"showMaximized":true,"showClose":true});
},
function(sender, args) {
alert('Error: ' + args.get_message());
}
);
}

var spjsOpenDocument = {};
spjsOpenDocument.Templates = {};
spjsOpenDocument.Templates.Fields = {
"SPJS_DocLink": {
"View":function(ctx){return spjs_logLinkClick(ctx);}
}
};
SPClientTemplates.TemplateManager.RegisterTemplateOverrides(spjsOpenDocument);

Add field to document library

Then you must add a new field to the document library named “SPJS_DocLink”. This is a calculated column with a blank formula:

=""

When the column has been created, you can rename it to for example “Open document with tracking”.

Add the field to the list view, and remove the “Name” column to prevent the users from opening the document with another method

Add JSLink scrip to the field

Use the Field JSLink too for SharePoint 2013 tool for setting the link to the JSlink file in the current field.

The path to use is the site relative path to the file you stored the above code example in. Use this format:

~site/DocLib/FileName.js

Add the list for logging the opening of documents

You must add a list to store log of the opened documents. This list must be placed in the same site as your document library.

The list must be named “DocumentsOpenedLog” as this is the name used in the code example. If you decide to change the display name of this list, you need to modify the code to use the new name.

In this example, the only field used in the “DocumentsOpenedLog” list is the Title. Therefore it is not necessary to add any more fields to this list.

Test the link

Go to your list view and click the link in the new field. The document should open in a dialog, and the “DocumentsOpenedLog” should show a new record with the document name in the “Title” field, and the name of the current user in the “Created by” field.

Discuss this code example in the forum

Alexander

SPJS-utility.js updated to v1.250 BETA 1

This version splits up “getFieldValue” and “setFieldValue” in separate functions for each of the field types. You still use them as before, but for advanced users you can now override the function for each individual field type.

In this new function layout you can for example override the function “getFieldValue_SPFieldText” to change how “getFieldValue” returns the value for a field of type “Single line of text”:

spjs.utility.getFieldValue_SPFieldText = function(a){
	return spjs.$(spjs.utility.data.fields[a.fin]).find('input').val();
}

This new layout will also let you add support for new file types in “getFieldValue” and “setFieldValue” by adding a function like this for “set”:

spjs.utility.setFieldValue_SPField[*****] = function(a){
	// change [*****] with the field type of your field, and add your custom getFieldValue logic here.
}

and like this for “get”:

spjs.utility.setFieldValue_SPField[*****] = function(a){
	// change [*****] with the field type of your field, and add your custom getFieldValue logic here.
}

Post any questions in the forum.

Keep in mind that this version id BETA and should not be used in a production environment.

vLookup connection from NewForm

With the latest version of vLookup for SharePoint (for SP2010 and 2013) you can add vLookup connections from NewForm.

This requires a few extra columns added to the parent and child list, and the setup is described in the user manual.

When adding children from NewForm, you must remember to save the parent form. If not, the newly created child items will be orphaned.

Read about the setup in the user manual, and add questions or comments in the forum.

Please note that the latest version or DFFS and vLookup is currently in BETA, and should not be used in a production environment.

Alexander

DFFS v4.25x still has a few bugs

Hi,
Unfortunately, DFFS v4.25x still has some bugs. There were made a few fundamental changes to how “initial value” was read, and this new query fails if the list contains more that “the allowed” number of lookup columns – this is columns of type “people picker”, “lookup”, “managed metadata / taxonomy fields”. The number of allowed lookup columns is set on the server side, so I will have to rethink how this query is performed.

I’m currently working on a fix, and will post an updated version during this weekend.

Post any questions or feedback here: https://spjsblog.com/forums/forum/dynamic-forms-for-sharepoint/

Sorry for the inconvenience,
Alexander

vLookup for SharePoint v2.0 is out

I have finally released v2.0 of my vLookup solution. There are a few new features, and it is better integrated into the DFFS backend.

You find the complete change log here.

Please note that this version does not have the “editor” built in to the frontend and you can no longer configure vLookup by adding ?vLookupSetup=1 to the URL. You must now configure vLookup from the DFFS_backend in the vLookup tab.

There has been some major changes to the code and you must test it in your setup before adding it to a production environment.

Folder support

One of the new features lets you have folders as children (in document libraries).

This way you can now add a folder from the vLookup “add child” link and have vLookup show all documents and subfolders added to this folder.

The metadata that makes the connection to the parent item is now on the folder and not the individual document.

Any documents uploaded to this folder will show in the parent item and there is no need to tag the individual documents with a connection to the parent item. It will show all documents and subfolders that are added to this parent folder.
IMG

I have also finally crated a user manual that describes the setup process and all the configuration options.

Get the new version

You find the link to download the new version in the Products menu in the top of this page.

Questions, comments or bugs

Please post any questions, bugs or feature requests in the forum.

Alexander

Dynamic Forms for SharePoint v4

Finally version 4 of my most popular solution is ready to be released!

This version adds new, as well as streamline existing functionality. You find the new version here.

I have also added a forum for discussions relate to the various solutions in this blog. I will close the comments section on the articles shortly, and route all discussions to the forum.

This will make it easier to find answers to questions already answered, and will make my support job easier.

Unfortunately you will have to register for a user account to add new topics, and to comment on existing. Due to problems with SPAM you will have to request a user account by email to me. You find the link as a sticky post in the top of all forums.

Please note:

The forums was added on September 3, 2014. At the moment, they are more or less empty.

You will however find a lot of comments on the different articles, and you might want to look trough those first.

I hope you enjoy the new version of DFFS, and that you participate in the discussions in the forum!

Best regards,
Alexander