Home › Forums › Classic DFFS › Realted items enabled?
- This topic has 7 replies, 2 voices, and was last updated 2 weeks, 5 days ago by
Alexander Bautz.
-
AuthorPosts
-
-
May 14, 2025 at 17:06 #38627
Hi Alexander, I was trying to have multiple attachment fields by adding an html section to my form that refers to a secondary list using – <div class=”relateditems” data-listname=”MakerCheckRelatedListAttachments”>. IT shows the html field but not the new item to add an attachment. Is this not possible? do have any suggestions a workaround?
-
May 14, 2025 at 18:06 #38629
Sorry, but I don’t have any solution for adding multiple attachment fields in the classic DFFS (it is possible to do that in the Modern DFFS version in SharePoint online).
An alternative for you would be to use the vLookup plugin and to store the attachments in a document library – tagged with metadata to associate them with the current list item. See the example for general vLookup configuration here: https://spjsblog.com/vlookup-for-sharepoint/vlookup-setup-example-for-sp-2010-and-2013/
Alexander
-
May 15, 2025 at 13:25 #38630
Thank you! ON another note, I have been trying to use JS to make one field disabled when three fields are equal to yes. Basically if one of the 3 fields is yes then the Attestation choice field is read only. For some reason no matter what I try I can’t get it to work. I have other JS in the form that is working great. I was wondering if it may be that I am not using a command that is available in DFFS. Would you be able to help? Here is the code. It is the function checkAndDisableField() function at the very end that I can’t get to work
// Check if the form is already in popup mode
if (window.location.href.indexOf(“popupReaderAct=1”) === -1) {
// Not in popup mode — open popup
window.open(
window.location.href + “?popupReaderAct=1”, // Add query to detect popup
“NewFormPopup”,
“width=800,height=600,resizable=yes,scrollbars=yes”
);// Redirect original window to AllItems view
window.location.href = “/sites/WOSS-APAC_MakerChecker/Lists/New%20Global%20Maker%20Checker%20Inventory/AllItems.aspx”;//} else {
// We’re in popup mode, run your existing logic (e.g., check role and hide tabs)//function checkUserRole() {
// var userId = _spPageContextInfo.userId;
//var queryUrl = _spPageContextInfo.webAbsoluteUrl + “/_api/web/lists/getbytitle(‘Roles’)/items?$filter=PersonId eq ” + userId;//fetch(queryUrl, {
//headers: { “Accept”: “application/json;odata=verbose” }
// })
// .then(response => response.json())
// .then(data => {
// if (data.d.results.length > 0) {
// var role = data.d.results[0].Role; // Capital “Role” if that’s the internal name// console.log(“Detected role:”, role);
//
// if (role.trim().toLowerCase() === “owner”) {
// spjs.dffs.toggleVisibleTab(“Owner”, true);
// spjs.dffs.toggleVisibleTab(“MakerChecker”, false);
// } else if (role.trim().toLowerCase() === “makerchecker”) {
// spjs.dffs.toggleVisibleTab(“MakerChecker”, true);
// spjs.dffs.toggleVisibleTab(“Owner”, false);
// }
// } else {
// console.log(“User has no role assigned.”);
// }
// })
// .catch(error => {
// console.error(“Error fetching role:”, error);
// });
// }//Wait for DFFS to be ready
// function dffsReadyCheckUserRole() {
// if (typeof spjs !== “undefined” && typeof spjs.dffs !== “undefined”) {
// console.log(“DFFS is ready, checking user role.”);
// checkUserRole();
//} else {
// console.log(“Waiting for DFFS…”);
// setTimeout(dffsReadyCheckUserRole, 200);
// }
// }dffsReadyCheckUserRole();
}
function setCurrentUser() {
setFieldValue(“ControlCertifiedUser”, _spPageContextInfo.userEmail);
//var today = new Date();
//var formattedDate = today.toISOString().split(“T”)[0]; // Format: YYYY-MM-DD
// setFieldValue(“Control_x0020__x2013__x0020_Last”, formattedDate);return false;
}function setCurrentUser1() {
setFieldValue(“ChecklistCertifiedUser”, _spPageContextInfo.userEmail);
// var today = new Date();
//var formattedDate = today.toISOString().split(“T”)[0]; // Format: YYYY-MM-DD
// setFieldValue(“Checklist_x0020__x2013__x0020_La”, formattedDate);return false;
}
function setCurrentUser2() {
setFieldValue(“CheckerInventoryCertifiedUser”, _spPageContextInfo.userEmail);
//var today = new Date();
//var formattedDate = today.toISOString().split(“T”)[0]; // Format: YYYY-MM-DD
// setFieldValue(“Checker_x0020_Inventory_x0020__x0”, formattedDate);return false;
}function checkAndDisableField() {
var val1 = getFieldValue(“Control_x0020_Certified_x003f_”);
var val2 = getFieldValue(“Checker_x0020_Inventory_x0020_Ce”);
var val3 = getFieldValue(“Checklist_x0020_Certified_x003f_”);if (val1 === “Yes” && val2 === “Yes” && val3 === “Yes”) {
setFieldValue(“Requesting_x0020_an_x0020_Except”, “No”);// Hook the function to field changes
setFieldTrigger(“Control_x0020_Certified_x003f_”, checkAndDisableField);
setFieldTrigger(“Checker_x0020_Inventory_x0020_Ce”, checkAndDisableField);
setFieldTrigger(“Checklist_x0020_Certified_x003f_”, checkAndDisableField);// Run once on form load
checkAndDisableField(); -
May 16, 2025 at 15:15 #38631
It looks like your code snippet is cut off at the bottom. Can you show me the complete “checkAndDisableField” function?
Alexander
-
May 16, 2025 at 18:08 #38632
Hi Alexander, Here is the latest code I have tried
// Check if the form is already in popup mode
if (window.location.href.indexOf(“popupReaderAct=1”) === -1) {
// Not in popup mode — open popup
window.open(
window.location.href + “?popupReaderAct=1”, // Add query to detect popup
“NewFormPopup”,
“width=800,height=600,resizable=yes,scrollbars=yes”
);// Redirect original window to AllItems view
window.location.href = “/sites/WOSS-APAC_MakerChecker/Lists/New%20Global%20Maker%20Checker%20Inventory/AllItems.aspx”;//} else {
// We’re in popup mode, run your existing logic (e.g., check role and hide tabs)//function checkUserRole() {
// var userId = _spPageContextInfo.userId;
//var queryUrl = _spPageContextInfo.webAbsoluteUrl + “/_api/web/lists/getbytitle(‘Roles’)/items?$filter=PersonId eq ” + userId;//fetch(queryUrl, {
//headers: { “Accept”: “application/json;odata=verbose” }
// })
// .then(response => response.json())
// .then(data => {
// if (data.d.results.length > 0) {
// var role = data.d.results[0].Role; // Capital “Role” if that’s the internal name// console.log(“Detected role:”, role);
//
// if (role.trim().toLowerCase() === “owner”) {
// spjs.dffs.toggleVisibleTab(“Owner”, true);
// spjs.dffs.toggleVisibleTab(“MakerChecker”, false);
// } else if (role.trim().toLowerCase() === “makerchecker”) {
// spjs.dffs.toggleVisibleTab(“MakerChecker”, true);
// spjs.dffs.toggleVisibleTab(“Owner”, false);
// }
// } else {
// console.log(“User has no role assigned.”);
// }
// })
// .catch(error => {
// console.error(“Error fetching role:”, error);
// });
// }//Wait for DFFS to be ready
// function dffsReadyCheckUserRole() {
// if (typeof spjs !== “undefined” && typeof spjs.dffs !== “undefined”) {
// console.log(“DFFS is ready, checking user role.”);
// checkUserRole();
//} else {
// console.log(“Waiting for DFFS…”);
// setTimeout(dffsReadyCheckUserRole, 200);
// }
// }dffsReadyCheckUserRole();
}
function setCurrentUser() {
setFieldValue(“ControlCertifiedUser”, _spPageContextInfo.userEmail);
//var today = new Date();
//var formattedDate = today.toISOString().split(“T”)[0]; // Format: YYYY-MM-DD
// setFieldValue(“Control_x0020__x2013__x0020_Last”, formattedDate);return false;
}function setCurrentUser1() {
setFieldValue(“ChecklistCertifiedUser”, _spPageContextInfo.userEmail);
// var today = new Date();
//var formattedDate = today.toISOString().split(“T”)[0]; // Format: YYYY-MM-DD
// setFieldValue(“Checklist_x0020__x2013__x0020_La”, formattedDate);return false;
}
function setCurrentUser2() {
setFieldValue(“CheckerInventoryCertifiedUser”, _spPageContextInfo.userEmail);
//var today = new Date();
//var formattedDate = today.toISOString().split(“T”)[0]; // Format: YYYY-MM-DD
// setFieldValue(“Checker_x0020_Inventory_x0020__x0”, formattedDate);return false;
}function checkAndDisableField() {
var val1 = document.querySelector(“[data-field=’Control_x0020_Certified_x003f_’]”)?.value || “”;
var val2 = document.querySelector(“[data-field=’Checklist_x0020_Certified_x003f_’]”)?.value || “”;
var val3 = document.querySelector(“[data-field=’Checker_x0020_Inventory_x0020_Ce’]”)?.value || “”;var allYes = val1 === “Yes” && val2 === “Yes” && val3 === “Yes”;
var targetField = document.querySelector(“[data-field=’Requesting_x0020_an_x0020_Except’]”);
if (targetField) {
targetField.disabled = allYes;
}
}// Run on load
checkAndDisableField();// Set change listeners
[“Control_x0020_Certified_x003f_”, “Checklist_x0020_Certified_x003f_”, “Checker_x0020_Inventory_x0020_Ce”].forEach(function (fieldName) {
var fieldEl = document.querySelector(“[data-field='” + fieldName + “‘]”);
if (fieldEl) {
fieldEl.addEventListener(“change”, checkAndDisableField);
}
}); -
May 16, 2025 at 19:52 #38634
Hi,
This does look like something cooked up by AI… Keep in mind that AI will aim to please you, but sometimes just imagines things.Try changing the function like this (I have not addressed the rest of the code – it might work, but I haven’t tested it):
function checkAndDisableField() { var val1 = getFieldValue("Control_x0020_Certified_x003f_"); var val2 = getFieldValue("Checklist_x0020_Certified_x003f_"); var val3 = getFieldValue("Checker_x0020_Inventory_x0020_Ce"); var allYes = val1 === "Yes" && val2 === "Yes" && val3 === "Yes"; if(allYes){ spjs.dffs.doReadOnly(["Requesting_x0020_an_x0020_Except"]); }else{ spjs.dffs.undoReadOnly(["Requesting_x0020_an_x0020_Except"]); } }
PS: Wrap any code you want to post inside <pre>…code here…</pre>
Alexander
-
May 16, 2025 at 20:32 #38635
ok, thank you I will try it. Also are calculated columns in a SharePoint list shown in DFFS?
-
May 16, 2025 at 22:47 #38637
Yes, but only in DispForm as in an out-of-the-box SharePoint list.
Alexander
-
-
AuthorPosts
- You must be logged in to reply to this topic.