Home › Forums › Classic DFFS › v4.4.5.55 has been released
Tagged: Classic DFFS
- This topic has 19 replies, 2 voices, and was last updated 1 week, 3 days ago by
Alexander Bautz.
-
AuthorPosts
-
-
April 7, 2025 at 18:16 #38545
I have published v4.4.5.55 of the Classic DFFS to fix a problem where the label of the attachment field was hidden when the field was set as readonly.
Alexander
-
April 14, 2025 at 17:31 #38551
Hello Alexander
I am hoping you can help me here. I am trying to launch a Custom JS script but it is not working. When I view the console here is the message I see
VM153:9 Uncaught ReferenceError: setFieldDisabled is not defined
at toggleFieldToDisable (<anonymous>:9:9)
at <anonymous>:14:1
at b (jQuery.js?v=1744295668044:2:866)
at He (jQuery.js?v=1744295668044:2:48648)
at E.fn.init.append (jQuery.js?v=1744295668044:2:49999)
at Object.loadCustomJS (eval at <anonymous> (DFFS_frontend_min.js:10:1), <anonymous>:1:202332)
at Object.loadDependencies (eval at <anonymous> (DFFS_frontend_min.js:10:1), <anonymous>:1:204183)
at HTMLDocument.eval (eval at <anonymous> (DFFS_frontend_min.js:10:1), <anonymous>:1:176726)
at e (jQuery.js?v=1744295668044:2:30310)
at t (jQuery.js?v=1744295668044:2:30612)and here is the JS I am trying to use
function toggleFieldToDisable() {
var f1 = getFieldValue(“Control_x0020_Certified_x003f_”);
var f2 = getFieldValue(“Checklist_x0020_Certified_x003f_”);
var f3 = getFieldValue(“Checker_x0020_Inventory_x0020_Ce”);if (f1 === “Yes” && f2 === “Yes” && f3 === “Yes”) {
setFieldDisabled(“Requesting_x0020_an_x0020_Except”, true);
} else {
setFieldDisabled(“Requesting_x0020_an_x0020_Except”, false);
}
}// Call it immediately on form load
toggleFieldToDisable();// Set up watchers so it also runs when these fields change
spjs.dffs.doReadOnlyOnChange.push({fin:”Control_x0020_Certified_x003f_”, functionName:toggleFieldToDisable});
spjs.dffs.doReadOnlyOnChange.push({fin:”Checklist_x0020_Certified_x003f_”, functionName:toggleFieldToDisable});
spjs.dffs.doReadOnlyOnChange.push({fin:”Checker_x0020_Inventory_x0020_Ce”, functionName:toggleFieldToDisable});setFieldDisabled(“Requesting_x0020_an_x0020_Except”, true);
I am not able to understand where I need to change the file location for JS and wondering if you can help me?
-
April 14, 2025 at 17:32 #38552
Here is a screenshot of the error
Attachments:
-
April 14, 2025 at 20:14 #38556
Hi,
This error states that you are missing a function named setFieldDisabled. If you have copied this custom js code from another site you must ensure you include this function also.Alexander
-
April 14, 2025 at 20:39 #38558
Thank you, I have to admit I am not very up on this. How do I get that funtion to include and where do I add it?
-
April 14, 2025 at 20:42 #38559
I have added the function to the Custom JS tab in DFFS and then I call it with a rule. Am I missing where else to add it?
-
April 14, 2025 at 20:45 #38560
Where did you get the rest of the code from? – I’m guessing the code has been copied from somewhere, but you forgot to include this one function.
Without knowing exactly what you want to do with the rest of the code I’m not sure if just writing a code example will work for you, but from the function name I’m guessing it could be done something like this:
function setFieldDisabled(fin, disabled){ if(disabled){ spjs.dffs.doReadOnly([fin]); }else{ spjs.dffs.undoReadOnly([fin]); } }
Alexander
-
April 14, 2025 at 21:02 #38561
Chat GPT gave me the code.
-
April 14, 2025 at 21:09 #38562
Do I add this piece of code that you gave at the end of the other code?
-
April 14, 2025 at 21:10 #38563
What I am trying to do is if all 3 fields are yes, then a 4th field is disabled but if ANY of those 3 fields is no then that field is NOT disabled
-
April 14, 2025 at 21:47 #38564
I see. Chat GPT have not given you code that will work when you toggle the fields – only when the form loads (if you add the missing function).
What kind of fields are f1, f2 and f3 – Yes/No fields, or choice fields where one of the options are Yes?
Alexander
-
April 15, 2025 at 13:11 #38565
The fields are choice fields.
-
April 15, 2025 at 15:50 #38566
What kind of choice field – radiobutton, dropdown or multiselect?
Alexander
-
April 15, 2025 at 16:00 #38567
This example should work for radiobutton fields:
const arrOfChoiceFields = ["Control_x0020_Certified_x003f_", "Checklist_x0020_Certified_x003f_", "Checker_x0020_Inventory_x0020_Ce"]; // Trigger on change arrOfChoiceFields.forEach(fin => { jQuery("#dffs_" + fin).find("input:radio").on("click", function(){ toggleFieldToDisable(); }); }); function setFieldDisabled(fin, disabled){ if(disabled){ spjs.dffs.doReadOnly([fin]); }else{ spjs.dffs.undoReadOnly([fin]); } } function toggleFieldToDisable(){ let allYes = true; arrOfChoiceFields.forEach(fin => { if(getFieldValue(fin) !== "Yes"){ allYes = false; } }); setFieldDisabled("Requesting_x0020_an_x0020_Except",allYes); } // Trigger on page load toggleFieldToDisable();
Please verify that I have the correct internal names for your fields.
Alexander
-
April 15, 2025 at 16:03 #38568
Thank you Alexander, how would I modify this to work with Choice Yes or no fields?
-
April 15, 2025 at 16:09 #38569
I need to know what you mean – is it a “Choice (menu to choose from) or a “Yes/No (check box) type field?
If it is the first, which subtype of field:
- Drop-Down Menu
- Radio Buttons
- Checkboxes (allow multiple selections)
Alexander
-
April 16, 2025 at 13:40 #38572
Hi Alexander,
They are dropdown. I am also getting another error on another piece of code. It seems like i don’t have the spjs.dffs? I am confused because some JS works and others don’t,
I am using this version DFFS_v4.4.5.55_2025-04-07.
This is the code. I am trying to just hide a tab based on a list that has a Person field and a Role field. I want to hide the tab based on the persons role. I attached the error as well. I feel like my problem is I am missing a file or something? Is there anyway I can get around this?
function checkUserRoleAndToggleTab() {
var currentUser = _spPageContextInfo.userLoginName;// Query the Roles list for current user
spjs.dffs.getListItems({
listName: “Roles”,
query: “<Where><Eq><FieldRef Name=’Person’ LookupId=’TRUE’ /><Value Type=’Integer’>” + _spPageContextInfo.userId + “</Value></Eq></Where>”,
viewFields: [“Role”],
onComplete: function (data) {
var hideTab = false;if (data.count > 0) {
var role = data.items[0].Role;// Check if role is “Owner”
if (role && role.trim().toLowerCase() === “owner”) {
hideTab = true;
}
}if (hideTab) {
spjs.dffs.hideTab(“test”);
} else {
spjs.dffs.showTab(“test”);
}
}
});
}// Run the function
checkUserRoleAndToggleTab();Attachments:
-
April 16, 2025 at 13:40 #38574
Hi Alexander,
They are dropdown. I am also getting another error on another piece of code. It seems like i don’t have the spjs.dffs? I am confused because some JS works and others don’t,
I am using this version DFFS_v4.4.5.55_2025-04-07.
This is the code. I am trying to just hide a tab based on a list that has a Person field and a Role field. I want to hide the tab based on the persons role. I attached the error as well. I feel like my problem is I am missing a file or something? Is there anyway I can get around this?
function checkUserRoleAndToggleTab() {
var currentUser = _spPageContextInfo.userLoginName;// Query the Roles list for current user
spjs.dffs.getListItems({
listName: “Roles”,
query: “<Where><Eq><FieldRef Name=’Person’ LookupId=’TRUE’ /><Value Type=’Integer’>” + _spPageContextInfo.userId + “</Value></Eq></Where>”,
viewFields: [“Role”],
onComplete: function (data) {
var hideTab = false;if (data.count > 0) {
var role = data.items[0].Role;// Check if role is “Owner”
if (role && role.trim().toLowerCase() === “owner”) {
hideTab = true;
}
}if (hideTab) {
spjs.dffs.hideTab(“test”);
} else {
spjs.dffs.showTab(“test”);
}
}
});
}// Run the function
checkUserRoleAndToggleTab(); -
April 17, 2025 at 09:57 #38587
To your original question – here is how you can change it to work with dropdown fields:
const arrOfChoiceFields = ["Control_x0020_Certified_x003f_", "Checklist_x0020_Certified_x003f_", "Checker_x0020_Inventory_x0020_Ce"]; // Trigger on change arrOfChoiceFields.forEach(fin => { jQuery("#dffs_" + fin).find("select").on("change", function(){ toggleFieldToDisable(); }); }); function setFieldDisabled(fin, disabled){ if(disabled){ spjs.dffs.doReadOnly([fin]); }else{ spjs.dffs.undoReadOnly([fin]); } } function toggleFieldToDisable(){ let allYes = true; arrOfChoiceFields.forEach(fin => { if(getFieldValue(fin) !== "Yes"){ allYes = false; } }); setFieldDisabled("Requesting_x0020_an_x0020_Except",allYes); } // Trigger on page load toggleFieldToDisable();
Alexander
-
April 17, 2025 at 10:03 #38588
Not over to your other question. First you cannot rely on Chat GPT knowing how to write the correct code – It might be good for writing general code, but specific to the methods used in DFFS it just isn’t. There is no method in DFFS called spjs.dffs.getListItems or spjs.dffs.hideTab / showTab…
Here is the correct code using the methods available in DFFS:
function checkUserRoleAndToggleTab() { // Query the Roles list for current user let res = spjs.utility.queryItems({ listName: "Roles", query: "<Where><Eq><FieldRef Name='Person' LookupId='TRUE' /><Value Type='Integer'>" + _spPageContextInfo.userId + "</Value></Eq></Where>", viewFields: ["Role"] }); var hideTab = false; if (res.count > 0) { var role = res.items[0].Role; // Check if role is "Owner" if (role && role.trim().toLowerCase() === "owner") { hideTab = true; } } if (hideTab) { spjs.dffs.toggleVisibleTab("test", false); } else { spjs.dffs.toggleVisibleTab("test", true); } } // Run the function checkUserRoleAndToggleTab();
You can find more information about the CRUD methods in the classic version of DFFS here: https://spjsblog.com/forums/topic/query-update-delete-an-item-in-javascript/
Alexander
-
-
AuthorPosts
- You must be logged in to reply to this topic.