Home › Forums › Classic DFFS › DFFS Built-in Function Reference – seeking volunteers
Tagged: PrevNextButtons
- This topic has 16 replies, 3 voices, and was last updated 3 years, 1 month ago by SteveE.
-
AuthorPosts
-
-
May 16, 2017 at 03:53 #16591
This is a call for anyone who would like to collaborate on producing a reference showing all the built in functions in DFFS that we can use in our custom JS code. I’m sure Alex could produce one, but I’d like to see if we could start a working group to take that load off Alex and produce at least a draft of such a reference ourselves, then ask Alex to review it/correct it/add to it. I would be glad to host it on a web site if needed, although Alex might be willing to add it somewhere on this site.
Is anyone interested in having such a reference? Helping build it?
-
May 18, 2017 at 22:22 #16622
Hi Keith,
Not much response yet, but I hope more people will post their code examples here – I’m sure it will be of great help for others to have a set of examples / references.As you know I’m a bit to busy to be able to write it up myself, but I’ll do my best to help out with any questions.
Thanks for the initiative,
AlexanderPS: I made it sticky.
-
May 22, 2017 at 14:40 #16633
// get/set field values.
// NOTE values are read from or written to the input field as strings.
// On save, they are converted by SP to the right data type
getFieldValue(‘FIN’)
setFieldValue(‘FIN’ , ‘valueToSet’)- This reply was modified 7 years, 6 months ago by Keith Hudson. Reason: improve spacing
-
May 23, 2017 at 06:03 #16640
//spjs_QueryItems
//retrieve items from a list
//takes an object containg the following parameters:
//listName, query, viewFields
spjs_QueryItems(argObj)example:
function getMacros(){
var fieldName = “Title”;
var fieldType = “Text”;
var listName = “Foods”;
var targetString = getFieldValue(“Food”);
var qty = getFieldValue(“Qty”);
var res, qb = [], item;
qb.push(“<Where>”);
qb.push(“<Eq>”);
qb.push(“<FieldRef Name='” + fieldName + “‘/><Value Type= ‘” + fieldType + “‘>” + targetString + “</Value>” );
qb.push(“</Eq>”);
qb.push(“</Where>”);
res = spjs_QueryItems({“listName”:listName,”query”:qb.join(“”),”viewFields”:[“PctFat”,”CalTot”,”PctCarb”,”PctProtein”]});
if(res.count > 0){
item = res.items[0];
setFieldValue(“TotCal”,item.CalTot !== null ? item.CalTot*qty: “not set”);
setFieldValue(“PctFat”,item.PctFat !== null ? item.PctFat*100: “not set”);
setFieldValue(“PctCarb”,item.PctCarb !== null ? item.PctCarb*100: “not set”);
setFieldValue(“PctProtein”,item.PctProtein !== null ? item.PctProtein*100: “not set”);
}
}Forum articles:
get values from another list/
vlookup-from-new-on-separate-list- This reply was modified 7 years, 6 months ago by Keith Hudson.
- This reply was modified 7 years, 6 months ago by Keith Hudson.
-
January 15, 2018 at 04:57 #19322
Putting Prev/Next tab buttons at the top of the form:
The easiest way to achieve this is to add this snippet to your custom js. You don’t need to use the Misc settings if you only want the buttons in the top.
var b = []; b.push("<div style='padding:2px;text-align:right;border-bottom: 1px #808080 solid;'>"); b.push("<input class='ms-ButtonHeightWidth' type='button' value='Previous tab' onclick='spjs.dffs.navTab(0);'>"); b.push("<input class='ms-ButtonHeightWidth' type='button' value='Next tab' onclick='spjs.dffs.navTab(1);'>"); b.push("</div>"); jQuery(".dffsTabRow").after(b.join(""));
(gleaned from https://spjsblog.com/forums/topic/general-dffs-enhancement-suggestions/#post-19314)
- This reply was modified 6 years, 10 months ago by Alexander Bautz. Reason: Wrapped code snippet in <code></code>
-
January 15, 2018 at 04:58 #19324
Redirecting user after Save button:
You can use this code in your custom js:
spjs.dffs.redirect(“http://Your_redirect_url”,false);
The redirect will be performed when saving the form.(Gleaned from https://spjsblog.com/forums/topic/general-dffs-enhancement-suggestions/#post-19314)
-
February 4, 2018 at 05:24 #19602
You can use this snippet to insert a timestamp in Custom JS:
spjs.dffs.buildValStr(“{timestamp[dd.MM.yyyy hh:mm:ss]}”);
// Outputs 03.02.2018 16:27:06From https://spjsblog.com/forums/topic/using-timestamp-in-custom-js/
-
May 4, 2018 at 00:05 #20828
Get current user name
var userInfo = spjs.utility.userInfo(spjs.dffs.data.currUserID);
// userInfo is an object with multiple properties – use console.log(userInfo) to see all
// Here is the title
alert(userInfo.Title);from: https://spjsblog.com/forums/topic/internal-function-to-get-current-logged-in-user/
-
May 4, 2018 at 01:01 #20830
make all visible tabs readonly, and set current tab fields to editable:
https://spjsblog.com/forums/topic/easy-way-to-make-all-fields-readonly/
-
May 11, 2018 at 23:53 #20894
Using Created and Created By in DFFS
Start by adding a HTML section in the tab with the Unique ID “CreatedBy”.Then add this to the Custom JS:
(function addCreatedByToTab(){
var b = [];
b.push(“<tr>”);
b.push(“<td class=’ms-formlabel’>”);
b.push(“<span class=’ms-h3 ms-standardheader’>Created by</span>”);
b.push(“</td>”);
b.push(“<td class=’ms-formbody’>”);
b.push(spjs.dffs.beforeProperties.Author[0]);
b.push(“</td>”);
b.push(“</tr>”);
jQuery(“#dffsHTML_CreatedBy”).replaceWith(b.join(“”));
})();from: https://spjsblog.com/forums/topic/using-created-and-created-by-in-forms/
-
May 17, 2018 at 22:59 #20929
Changing tab colors
/* Style base tab */
li.tabBase a{
background-color:gray!important;
padding:0 2px!important;
}
li.tabBase span{
color:black!important;
}
/* Style selected tab */
li.tabSelected a{
background-color:green!important;
padding:2px!important;
}
li.tabSelected a span{
color:yellow!important;
}from https://spjsblog.com/forums/topic/css-style-of-selected-tab/
-
May 17, 2018 at 23:16 #20935
spjs.dffs.triggerSave(); saves record
-
May 21, 2018 at 17:00 #20952
Programmatically set required field:
Required fields are stored in this array:
spjs.dffs.data.requiredFieldsand you can push in new fields like this
// Push new required field into array
spjs.dffs.data.requiredFields.push(“YourFieldName”);
// Show star on all required fields
spjs.dffs.starRequired();If you need to remove a field from the array, you can use this function:
spjs.dffs.data.requiredFields = spjs.dffs.removeFromArr(spjs.dffs.data.requiredFields,”YourFieldName”);From: https://spjsblog.com/forums/topic/programmatically-set-required-field/
See also: https://spjsblog.com/forums/topic/programmatically-set-field-to-required-based-on-multiple-inputs/- This reply was modified 6 years, 6 months ago by Keith Hudson.
-
August 3, 2018 at 15:01 #21634
Set All Fields on a Tab to readonly:
Add this snippet to your Custom JS and call it from the “Click function name” in your tab:
function readOnlyAllFieldsInTab(){
var arrToSetReadonly = [];
jQuery.each(spjs.dffs.data.tabConfigObj[spjs.dffs.data.selectedTab].fields,function(i,fin){
if(spjs.dffs.fieldData[fin] !== undefined){
arrToSetReadonly.push(fin);
}
});
spjs.dffs.doReadOnly(arrToSetReadonly);
}
Please note that the fields will stay read-only when you change tabs – you would have to set the fields as editable again in the other tabs. -
September 22, 2018 at 17:47 #22175
Add Prev/Next buttons at top of form
var b = []; b.push("<div style='padding:2px;text-align:right;border-bottom: 1px #808080 solid;'>"); b.push("<input class='ms-ButtonHeightWidth' type='button' value='Previous tab' onclick='spjs.dffs.navTab(0);'>"); b.push("<input class='ms-ButtonHeightWidth' type='button' value='Next tab' onclick='spjs.dffs.navTab(1);'>"); b.push("</div>"); jQuery(".dffsTabRow").after(b.join(""));
from: https://spjsblog.com/forums/topic/general-dffs-enhancement-suggestions/#post-19314
- This reply was modified 6 years, 2 months ago by Alexander Bautz. Reason: fixed code snippet
-
May 31, 2019 at 13:54 #25530
Adding Delete Button to vLookup table
https://spjsblog.com/forums/topic/delete-button-on-vlookup-table/#post-25523
-
October 20, 2021 at 16:59 #34871
Set date in new field based on another field.
function SetDate(){ var StartDate = spjs.utility.getDateFieldAsDateObject("StartDateField"); spjs.utility.setDateFieldFromDateObject("EndDateField",StartDate,14); }
-
-
AuthorPosts
- You must be logged in to reply to this topic.