kitmenke / sputility Goto Github PK
View Code? Open in Web Editor NEWA JavaScript library used to make modifications to SharePoint's list forms (NewForm.aspx and EditForm.aspx in a survey, custom list or library).
License: MIT License
A JavaScript library used to make modifications to SharePoint's list forms (NewForm.aspx and EditForm.aspx in a survey, custom list or library).
License: MIT License
Created from #22
MakeReadOnly on an empty numeric field results in NaN.
Date time fields contain multiple controls: a calendar control (textbox) for the date, a dropdown for hour, and a dropdown for minute.
The current API supports setting just date and date plus time. It does not support setting Time only.
API should support the ability to set just the time and force the user to fill out the date.
var field = SPUtility.GetSPField('Date and Time');
field.SetTime(8, 30);
field.SetTime('6 PM', '00');
Support SPFieldUserMulti fields where the HTML comment is missing.
Reported here: http://sputility.codeplex.com/discussions/654914
Support SPFieldLookup fields where the HTML comment is missing.
Reported here: http://sputility.codeplex.com/discussions/654914
Support SPFieldFile fields where the HTML comment is missing.
Reported here: http://sputility.codeplex.com/discussions/654914
Created from https://sputility.codeplex.com/workitem/31
field.MakeReadOnly() displays 12:00 AM for null Date (SPFieldDateTime) field on the edit form.
I think it shouldn't display anything (empty string).
The field was provisioned with Type="DateTime"This happens on SharePoint 2010 (did not test on 2013).
The code below can't detect DispForm for document libraries:
if (formBodies.length > 0 && $(formBodies[0]).children().length === 0) {
_isDispForm = true;
}
Need to find better alternative, maybe look at the form's buttons?
Добрый день, Ваш пример не работает в SPS Russian language
SPUtility.GetSPField('Кем проверен кандидат').SetValue('Hello world!');
sputility.min.js:10 Uncaught Unable to get a SPField named Кем проверен кандидат
$.GetSPField @ sputility.min.js:10
Пробовал StaticName указать:
SPUtility.GetSPField('FirstEdit').SetValue('Hello world!');
sputility.min.js:10 Uncaught Unable to get a SPField named FirstEdit
Support SPFieldMultiChoice fields where the HTML comment is missing.
Reported here: http://sputility.codeplex.com/discussions/654914
From: https://sputility.codeplex.com/discussions/647717
Uncaught Error creating field named ContractID: getSPFieldType error: TypeError: Cannot read property 'childNodes' of undefined
Error is coming out of createSPField because spFieldParams.controlsCell is null. Probably something going wrong in getFieldParams because it is not correctly detecting SharePoint 2013 Survey forms.
SPDateTimeField should accept SPDateTimeFieldValue as a single parameter in addition to the parameters separated out (year, month, day, hour, minute)
Support SPFieldNote fields where the HTML comment is missing.
Reported here: http://sputility.codeplex.com/discussions/654914
Support SPFieldDateTime fields where the HTML comment is missing.
Reported here: http://sputility.codeplex.com/discussions/654914
Support SPFieldCurrency fields where the HTML comment is missing.
Reported here: http://sputility.codeplex.com/discussions/654914
Support SPFieldGridChoice fields where the HTML comment is missing.
Reported here: http://sputility.codeplex.com/discussions/654914
Support SPFieldChoice fields where the HTML comment is missing.
Reported here: http://sputility.codeplex.com/discussions/654914
Support SPFieldText fields where the HTML comment is missing.
Reported here: http://sputility.codeplex.com/discussions/654914
Single line of text field in IE 11
Example -
SPUtility.GetSPField('CustomerCode').MakeReadOnly();
CustomerCode = "R&DI"
When form is displayed is only displays R and not R&DI
MakeReadOnly turns the field into a label correctly but MakeEditable doesn't undo the changes correctly.
Reported by GenericCodeMonkey:
When I want to get a LookupField in the DisplayForm i get the Exception:
throw "Unable to get input elements for " + this.Name;
from SPAutocompleteLookupField(fieldParams, elemInputs)
because elemInputs is passed with a length of 0 from getSPFieldFromType(spFieldParams)
at case 'SPFieldLookup'
My workaround is to just not throw the exception:
function SPAutocompleteLookupField(fieldParams, elemInputs) {
SPField.call(this, fieldParams);
if (this.Controls === null) {
return;
}
if (1 === elemInputs.length) {
// autocomplete lookup
this.Textbox = $(elemInputs[0]);
this.HiddenTextbox = $('input[id="' + this.Textbox.attr('optHid') + '"]');
} else {
return;//MyFix
throw "Unable to get input elements for " + this.Name;
}
}
Attempting to hide the Title field on DispForm results in this error:
Uncaught Error creating field named Title: Unable to retrieve the input control for Title
Support ContentTypeChoice fields where the HTML comment is missing.
Reported here: http://sputility.codeplex.com/discussions/654914
Support SPFieldURL fields where the HTML comment is missing.
Reported here: http://sputility.codeplex.com/discussions/654914
Hello,
I'd like to submit 2 bug fixings and 2 new features.
this.upLevelDiv = $("#" + this.spanUserField.id + '_upLevelDiv');
this.textareaDownLevelTextBox = $("#" + this.spanUserField.id + '_downlevelTextBox');
this.linkCheckNames = $("#" +this.spanUserField.id + '_checkNames');
this.txtHiddenSpanData = $("#" +this.spanUserField.id + '_hiddenSpanData');
GetValue() (line 1291)
this.GetValue = function () {
var peopleSpans = this.upLevelDiv.find('span.ms-entity-resolved');
if (peopleSpans.length > 0) {
return arrayToSemicolonList(peopleSpans);
}
return '';
};
this.Description = (function(ctls) { var c = ctls.childNodes[ctls.childNodes.length-1]; return (c.nodeType!=3 || $(c).text().replace(/\s/g,'').length == 0)? null : c; })(fieldParams.controlsCell);
var currentValue = null;
this.OnChange = function(fn) {
var handler = getMethodName(fn) + "()";
$(this.upLevelDiv[0], this.textareaDownLevelTextBox[0]).attr("onvaluesetfrompicker", handler);
currentValue = this.GetValue();
this.upLevelDiv.blur($.proxy(function() {
if (this.GetValue() !== currentValue) {
currentValue = this.GetValue();
fn();
}
}, this));
};
Usage:
SPUtility.GetSPField("Nominated User").OnChange(requestUser);
function requestUser() {
var val = SPUtility.GetSPField("Nominated User").GetValue();
if (!val.length) return;
alert(val);
}
And this method to get the list of resolved users by loginName/display Name:
this.GetUsers = function() {
var people = [], peopleSpans = this.upLevelDiv.find('span.ms-entity-resolved');
if (peopleSpans.length > 0) {
$(peopleSpans).each(function () {
var c = this.firstChild;
people.push({ id: c.getAttribute('key'), title: c.getAttribute('displaytext') });
});
}
return people;
};
Of course, feel free to rename the methods as you want.
Tested on IE 8 & Chrome
Hi,
please add your package to npm public repository. It would help all developers which use npm for their package repository a lot. In my company we are currently shifting from bower to npm
Thank you,
Viktor
The current separator is hard coded to '/'. Allow customizing the separator so that this works with other countries.
For example: '.'
SPUtility.GetSPField return 50 instead of 50.000
Before:
Title 50.000 (fifty thousand in the European numbering system)
var myField = SPUtility.GetSPField('Title');
myField.MakeReadOnly();
After:
Title 50 (fifty)
I use SP2007
Can you fix the problem?
Thanks
Stefano
SPUserField not working with jQuery 1.9 because of the line:
this.SetValue = function (value) {
1518: if ($.browser.msie) {
because jQuery seems to have deprecated this .msie line (see http://api.jquery.com/jquery.browser/)
Is there a version uses say:
var isIE = ("ActiveXObject" in window)
See: http://stackoverflow.com/questions/17907445/how-to-detect-ie11
Support SPFieldUser fields where the HTML comment is missing.
Reported here: http://sputility.codeplex.com/discussions/654914
I am facing this problem when using SPUtility.js inside my SP 2013 on-premises, now i want to do the following inside my sharepoint 2013 list forms:-
now to make my Choice field ReadOnly i use the following SPUtility method:-
SPUtility.GetSPFieldByInternalName('OrderStatus').MakeReadOnly();
but when i tired to change the value of the list after making it ReadOnly, as follow:-
SPUtility.GetSPFieldByInternalName('OrderStatus').SetValue("In Progress");
OR using pure javascript appraoch as follow:-
$('[id^="OrderStatus"]').val("In Progress");
i was unable to change the status value? so can anyone adivce how i can handle this problem? so i can change the value of a ReadOnly list?
second point, is there a way i can temporary remove the MakeReadOnly() effect on the field? if this is possible , then i can remove the ReadOnly effect on the Choice field, then set its value, then make it as ReadOnly again ?
Thanks
Support SPFieldNumber fields where the HTML comment is missing.
Reported here: http://sputility.codeplex.com/discussions/654914
Can anyone please assist me on how IsRequired is implemented because it doesn't seem to work on my side.
Steps to repro:
On the EditForm, a Content Type field is now displayed at the top. Expected behavior would be to get the value of this field like: SPUtility.GetSPField('Content Type').GetValue();
Issue is: SPUtility is unable to determine the type of the Content Type field and returns null.
Add support for External Data fields.
SharePoint 2007, Date and Time field:
Calling SPUtility.GetSPField('Date and Time').MakeReadOnly() makes the field read only OK.
Then calling:
SPUtility.GetSPField('Date and Time').SetValue(2014,3,14,'1 AM','00')
clears the label instead of updating it.
Support SPFieldBoolean fields where the HTML comment is missing.
Reported here: http://sputility.codeplex.com/discussions/654914
Multi-select lookup fields use buttons to move selected options between the two select boxes.
In Firefox, calling SetValue multiple times in a row can result in a value not being set.
This issue does not seem to affect Chrome.
TODO: test IE
On DispForm.aspx GetValue throws an exception when used. https://sputility.codeplex.com/discussions/646901
It should at the very least be able to return a string value of the field but it would be nice to convert to the right type like on NewForm and EditForm.
Right now only SPNumberField, SPBooleanField, and SPUserField2013 have this method. It would be nice if all the fields implemented the GetValueString method so that you could do easy comparisons (before and after for example).
SPUserField2013 GetValue returns this.ClientPeoplePicker.GetAllUserInfo(); and MakeReadOnly uses this to set the label's text. Instead, it should pull out the user's name and display that in the label.
SharePoint 2007
SPUtility.GetSPField('Multi-value Lookup').MakeReadOnly()
Gives error: "Object doesn't support this property or method"
I am trying to get SPutility to work in Sharepoint online. I could not get any scripts to work in neither script editor nor content editor web parts. I don't have access to custom forms advanced mode editing (yet - i hope i will get it soon from the admin). I managed to find a workaround by using Form HTML webpart and editing its source code and putting my script there. jQuery works and gives me the test alert, but nothing happens when i try to get an alert from SPUtility. ( I also tried using some functions on the form like autocomplete but no luck there as well. Here's the code:
<script language="javascript" type="text/javascript" src="/SiteAssets/jquery-3.2.1.js"></script>
<script language="javascript" type="text/javascript" src="/SiteAssets/jquery.SPServices.min.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function() {
alert("jQuery");
alert($().SPServices.SPGetCurrentSite());
});
</script>
Support SPFieldLookupMulti fields where the HTML comment is missing.
Reported here: http://sputility.codeplex.com/discussions/654914
SetValue works the first time you call the method. Then, the "possible values" list loses focus and subsequent calls stop working.
Not working in SharePoint 2013.
Allow retrieving a fields by internal column name.
Currently lazyLoadSPFields works quickly by only finding the display names. To index internal column names, each field would have to be parsed which can cause performance issues with large lists.
Considering adding a new method or an overload of GetSPField to allow this.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.