Forum Replies Created
-
AuthorPosts
-
ok, thank you I will try it. Also are calculated columns in a SharePoint list shown in DFFS?
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);
}
});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();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();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:
Thank you Alexander, how would I modify this to work with Choice Yes or no fields?
The fields are choice fields.
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
Do I add this piece of code that you gave at the end of the other code?
Chat GPT gave me the code.
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?
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?
Here is a screenshot of the error
Attachments:
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?
Hi Alexander,
Would you be able to tell me how I make an HTML header section collapsible and expandable? Also is there a way to pop up a preview of email before it is sent in a window?
-
AuthorPosts