All posts by Alexander Bautz

Redirect from NewForm to EditForm in DFFS

Change log
September 23, 2016
I had forgot to add “return false” in the PreSaveAction function – this could result in duplicates being added to the list.
January 05, 2016
Changed the code example to include the “InDlg” attribute if you are in a dialog.

Here is an alternative solution for redirecting from NewForm to EditForm when using DFFS.

This solution is based on entering NewForm, filling in the Title field, and hitting “Save” to continue in EditForm.

Here is an example on a NewForm

SaveAndContinue

Add this code to the Custom JS

function saveAndRedir(){
	var ok = spjs.dffs.check_Mandatory(["Title"]), data = {}, newItem, url;
	if(ok){
		data.Title = getFieldValue("Title");
		newItem = spjs.utility.addItem({"listName":_spPageContextInfo.pageListId,"data":data});
		if(newItem.success){
			url = location.pathname.substring(0,location.pathname.lastIndexOf("/")) + "/EditForm.aspx?ID="+newItem.id;
			if(GetUrlKeyValue("IsDlg")==="1"){
				url += "&IsDlg=1";
			}
			location.href = url;
		}else{
			alert(newItem.errorText);
		}
	}
}

function PreSaveAction(){
	saveAndRedir();
	return false;
}

This is it – test it and let me know how it works out  in the Forum.

Best regards,
Alexander

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

nSPTiles: Windows style tiles for SharePoint by Anchal Nigam

Some time ago Anchal Nigam asked if it was OK to make a spin-off based on my SharePoint 2013 style tiles solution.

This was no problem to say yes to as my tiles solution has fallen a bit behind on the updates due to other projects – mostly DFFS.

I have now finally fond the time to try out his solution, and it is great!

There is a lot more configuration options than in my original version, and best of all: it has a GUI to create or edit the tiles directly in a grid on the page.

Check it out here: http://nsptiles.js.org/

nSPTilesImage borrowed from the Wikipedia article on Bart Simpson

Please note

This is not a sponsored review. I have written this as a courtesy to Anchal.  I have nothing to do with this solution, and therefore all related questions must be posted in the page linked above.

Alexander

 

License agreement for Site collection scoped licenses has been updated

Based on feedback from “corporate users” I have decided to remove the “100 user limit” for the Site collection scoped license.

This means that the “Site collection license” and the “Corporate user license” can now be used in site collections with more than 100 users without violating the license terms.

Read more about the updated license terms here.

Best regards,
Alexander

Dynamic forms for SharePoint v4.350 is out!

Production release is out!

I have finally finished the production release of DFFS v4.350 and vLookup v2.250 after a long BETA test period. I have not had all that much feedback on the latest BETA, and this can either mean there were no bugs, or that not so many have tested it.

I hope it is the first!

What is new?

The change log will be updated as soon as I can manage, but here is a few vital changes.

The installation process for all but the JSLink version for SP2013 has changed since the last production release. You find information in the updated installation manual. The user manual has also been updated with most of the new features, but I still have some parts left.

If you find a feature you cannot figure out, please look in the forum to see if the question has already been answered. If you cannot find it there, please post a new topic in the forum.

If you don’t have a user account, you find information in the top of each forum.

New license handling

All existing license codes (except the JSLink version) must be updated to a new format to support this new release.

This means you must send me an email to request an updated license.

Site collection scoped licenses

All site collection scoped licenses requires a “Challenge-Response” routine to generate the license key.

Please note that a site collection scoped license can only be used with one site collection. If you need more, you must upgrade your license. Read more here.

JSLink setup option

You find the “Challenge code” generation in the “Setup” page you created in the SPJS library.

CEWP setup option

You find a “License” tab in the backend or DFFS. The license added here will affect all DFFS instances in the current site.

Important information

I try to maintain backwards compatibility with older versions, but I cannot guarantee that all old configurations will upgrade without issues.

Back up you configuration before upgrading

Please BACK UP your configuration first by going to the Misc tab and Export the configuration to a text file.

This way you can restore your previous version if something did not perform as expected.

Plugins

All the plugins used with DFFS is included in this package

Download

Get the package here

Installation

See installation manual and user manual.

Best regards,
Alexander

 

 

 

DFFS and vLookup BETA 3

The documentation is not updated with the BETA 3 changes. This will follow as soon as I can manage.
You find the updated files here

I have finally finished the hopefully last BETA of DFFS and vLookup.

The DFFS BETA 3 is compatible with SharePoint 2007, 2010 and 2013, but the BETA 3 of vLookup is for SP2010 and 2013 only. I have not updated vLookup for SP 2007.

Normally, BETA 3 would contain only bugfixes from BETA 2, but I ended up adding a few new features also – like “print” and “email”, a visually brushed-up DFFS backend, and a bit more.

Use the “help icons” in DFFS backend to learn about the new features. See “Documentation” below for more info.

License code handling

The license code has now moved into the DFFS backend configuration (not for the JSLink version).

I have also updated the license code validation to make all versions use the same “format” on the license code.

This mean all but the JSLink version license codes must be updated.

If you have a valid DFFS v4 license you can send me the old license code, and I’ll send you a new one – free of charge.

Please note

I cannot guarantee full backwards compatibility for all older configurations. Please BACK UP your configuration first by going to the Misc tab and Export the configuration to a text file.

This way you can restore your previous version if something did not perform as expected.

Documentation

I have put in a HUGE amount of work in this new version, and as is is long overdue my original release date, I was keen to get it published as soon as I possibly could.

This means I have not been able to update all the documentation for the new version.  This will follow – hopefully tomorrow, but here is a few short notes.

Installation of “CEWP” version

(all but the JSLink verson of SharePoint 2013.)

I have now added a folder “CEWP” to the download package. This contains updated versions of the “DFFS_frontend_CEWP.html”, “DFFS_frontend_overlay.html” and “DFFS_backend_CEWP.html”.

The recommended location for all the DFFS files is in a document library named “SPJS” in the root of each site (or in the root of the site collection).

When the solution is out of BETA

You must update your existing CEWP code to use the latest DFFS and plugins from this package. Ideally, you should change all existing CEWP’s in all your forms to point to the new files. This will make future updates easier to manage as all files has it’s designated location.

Special focus points for testing

The one point I’m most keen to get reports on, is large lists with a lot of rules. I have changed the trigger handling part of the code, and hope it has become more efficient. If you find your form using a long time to load, please consider reworking the rules, and utilize the new functionality to “Stop if this rule = true, and jump to” functionality on the triggers.

You can also control the “reversing” for each individual rule to prevent unnecessary processing of “reversed rules”.

Questions and feedback

Use the forum for all issues with general interest. If you don’t already have an user account, you find instructions in the sticky post in the top of the forum.

Best regards,
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