Home › Forums › Classic DFFS › Rule issue with multiple content types
- This topic has 11 replies, 2 voices, and was last updated 5 years, 7 months ago by Leonid.
-
AuthorPosts
-
-
March 26, 2019 at 22:15 #24476
I have a SP list with multiple content types.
Several content types have a Person field “TrainingCoordinator” and some don’t. The form has a Rule that checks peoplepicker for that field. When the EDIT form comes up for a content type which doesn’t have “TrainingCoordinator” field, DFFS throws an error attached. Even with linked rule defined to check for the content type, error still thrown. The EDIT form works fine when called on other content types.Attachments:
-
March 27, 2019 at 14:19 #24484
-
March 27, 2019 at 17:27 #24488
Hi,
When you use content types you will have to create rules that only triggers if you have a specific content type.I suggest adding a rule in the top of the rules section for each of the content types and have them trigger on “Content type = your content type”. These rules does not have to do anything, but you can use them in the “Linked rules and functions” in your other rule to ensure it only triggers if the correct content type is detected.
I generally don’t recommend using content types with DFFS – you can create the different form layouts using rules and tabs in DFFS to mimic the functionality.
Alexander
-
March 27, 2019 at 18:06 #24492
Alex,
That’s pretty much what I’ve tried. Yet, Even when the rule is NOT a match, DFFS error still thrown as if the rule is processed. Here’re snapshotsAttachments:
-
March 27, 2019 at 20:32 #24499
OK, it seems the function that tries to validate the people picker fails when the field is not in the content type. You need to make some changes and create two rules like the attached images, and then one function in Custom JS like this:
function isCorrectCT_setPeoplePicker(){ var isTC = spjs.dffs.beforeProperties.TrainingCoordinator_ID[0] === String(_spPageContextInfo.userId); if(isTC){ spjs.dffs.triggerRule(["isTC_CallFromCustomJS"]); } }
Please note that you should NOT use quotes around the content type names in the rule trigger “This value” field.
Let me know how this works out.
Alexander
Attachments:
-
March 27, 2019 at 21:25 #24503
Thanks Alex,
In my scenario the rule checks if current user is the one in peoplepicker. That’s where the error happens. Do I understand correctly that I cant use the rule trigger for that and have to use javascript function to compare current user with peoplepicker?The preferred solution would be to allow rules on every field present in list definition regardless of which content type it belongs to.
-
March 27, 2019 at 23:30 #24505
You can use the workaround I suggested, but I’ll look into changing it so it will not throw this error, just return false if the field it not present.
Alexander
-
March 28, 2019 at 15:15 #24523
Awesome, Alex, thanks!
BTW,spjs.dffs.beforeProperties
is a hidden gem!
-
March 28, 2019 at 20:24 #24527
To close this topic, is there DFFS syntax to add actual field control programmatically?
I understand that control’s values can be added as {<control_name>} and {{<control_name>}}. Say if my control is a choice dropdown, is there a way to add it vs writing the whole HTML? -
March 28, 2019 at 21:29 #24529
No, DFFS does not insert these controls, it overlays the default form and uses the already available controls.
Alexander
-
April 4, 2019 at 20:12 #24697
-
April 4, 2019 at 22:00 #24703
Never mind, found an problem with reversing rules…
-
-
AuthorPosts
- You must be logged in to reply to this topic.