Home › Forums › Classic DFFS › Issue with rules related to people pickers
- This topic has 7 replies, 2 voices, and was last updated 3 days, 23 hours ago by Alexander Bautz.
-
AuthorPosts
-
-
October 31, 2024 at 18:25 #38197
Hey Alex,
In a list I still use classic on (which 90% of my DFFS is still on classic — I’m on v4.4.5.35) I’m having issues with rules that deal with people pickers not firing consistently.
I have a rule that says If [PeoplePicker] is equal to [blank]
When I say [blank] I mean I literally put no text or anything in the “This Value” section, I just leave it empty because I’m wanting to check if the field is empty or not.
This works like 50% of the time, and it has to be related to the user profile entered into that field not validating on time. I’ve extended DFFS loading by 5000ms and it gets a little better, but still has issues. I’ve even had it delayed up to 10000ms and I can’t keep raising the delay.
Is there a workaround for this?
-
October 31, 2024 at 20:59 #38198
Hi,
Are you using a rule triggering on form load or on field change?It can be done using custom js so If you can give me some more details I can give you a code example.
Alexander
-
November 1, 2024 at 15:54 #38203
I have tried both onload only and onload and onchange. It’s not that it doesn’t work, because it does… just not consistently. The rule evaluates before the peoplepicker resolves. What I noticed is that onchange it doesn’t revalidate.
Setup is the rule for PeoplePicker is equal to [blank] and then I don’t do anything with it at that point. What I do is I reference that in a Linked Rules and Functions section of other rules and I have the box checked so that a change in that rule will revalidate the parent rule. That’s where I’m seeing the inconsistent experience.
-
November 2, 2024 at 09:24 #38206
You can try using this Custom JS instead of using rules to detect the change on the PP.
function peoplePickerChanged(fin){ var currPPvalue = spjs.dffs.beforeProperties[fin]; if(currPPvalue.length === 0){ console.log("The field is empty on form load"); } setInterval(() => { let val = getFieldValue(fin); let isResolved = spjs.utility.getFieldValue({"fin": fin, "key": "isresolved"}); if(!isResolved.includes(false) && String(currPPvalue) !== String(val)){ currPPvalue = val; console.log("Changed to", val); if(val.length === 0){ console.log("Is empty"); } } },1000); } peoplePickerChanged("PeoplePicker1");
Alexander
-
November 15, 2024 at 00:41 #38292
Thanks, I will try this. Just so you can see what I’m talking about, here’s an example. I have the delay load in the MISC tab set to 5000 ms and still you can see that the people pickers that get set to read only are showing blank, even though the actual field has people listed in them. Fields in this screenshot are Completed By and Employees.
Attachments:
-
November 15, 2024 at 01:21 #38294
Attached you will find the results of the console logs from your script. This is very interesting, and I cannot explain it. Notice that the logs never say “The field is empty on form load”. Rather, it’s saying that the fields are CHANGED to empty, and then seconds later, says they are changed to their current values. This is on Edit form. Those fields have values in them. When the form is loaded, they have values, I don’t know why it says they were changed to blank, and then just 1-2 seconds later says changed to what they actually are. Notice that DFFS load time tracker logs in between these actions. Something is off here, I can’t figure out what it is, but it’s a timing issue with something. There are no rules clearing these fields out.
Attachments:
-
November 15, 2024 at 02:17 #38296
I got your script to work, this is what I came up with after tweaking it. Notice that I had to call the function for every peoplepicker. It works though.
~~~~
function peoplePickerChanged(fin){
var currPPvalue = spjs.dffs.beforeProperties[fin];
console.log(currPPvalue);
if(currPPvalue.length === 0){
console.log(fin + ” field is empty on form load”);
spjs.dffs.hideFieldsByRule(fin);
}
setInterval(() => {
let val = getFieldValue(fin);
let isResolved = spjs.utility.getFieldValue({“fin”: fin, “key”: “isresolved”});
if(!isResolved.includes(false) && String(currPPvalue) !== String(val)){
currPPvalue = val;
console.log(currPPvalue);
console.log(fin + ” changed to”, val);
if(val.length === 0){
console.log(fin + “is empty”);
}
else {
spjs.dffs.doReadOnly(fin);
spjs.dffs.unhideFieldsByRule(fin);
}
}
},1000);
}
peoplePickerChanged([“Employees”]);
peoplePickerChanged([“Employee”]);
peoplePickerChanged([“NewAM”]);
peoplePickerChanged([“Manager”]);
peoplePickerChanged([“Agent_Name”]);
peoplePickerChanged([“CenterPOC”]);
peoplePickerChanged([“CurrentAM”]);
peoplePickerChanged([“NewManager”]);
peoplePickerChanged([“Center_Sales_Manager”]);
peoplePickerChanged([“NewDirector”]);
peoplePickerChanged([“CurrentManager”]);
peoplePickerChanged([“CurrentDirector”]);
peoplePickerChanged([“EmployeeTrade”]);
peoplePickerChanged([“TrainingPlacement”]);
peoplePickerChanged([“ApprovedByManager”]);
~~~~
-
-
November 17, 2024 at 08:47 #38305
The people picker field loads async because it evaluates all entries to ensure they are valid choices. I assume that this process is slow for some reason.
I’m glad you figured out a solution.
Alexander
-
-
AuthorPosts
- You must be logged in to reply to this topic.