Home › Forums › Classic DFFS › Rule with Lookup field
- This topic has 12 replies, 3 voices, and was last updated 4 years, 9 months ago by Alexander Bautz.
-
AuthorPosts
-
-
November 25, 2019 at 17:21 #27726
I have a multiple lookup field, type of SPFieldLookupMulti.
The fields isnt listed in Rules. Is that a limitation or Im missing something? -
November 25, 2019 at 18:25 #27728
adding to above: the SPFieldLookupMulti field is not exposed in
`spjs.dffs.beforeProperties -
November 25, 2019 at 21:59 #27733
Hi,
Unfortunately a multi lookup column cannot be used as a trigger. You can use a trigger of type “Custom javascript function” and write your custom code in a function in Custom JS – returning true or false to use it on form load.If you need to have it triggering on change you must write some custom js to sense it changing and then use a custom function to do your magic.
I tested now and my multilookup column does show in spjs.dffs.beforeProperties. Maybe there is some difference with older versions of SharePoint – which version are you on?
Alexander
-
November 26, 2019 at 16:39 #27741
Alex,
This is SP Online. I checked spjs.dffs.beforeProperties in dffs_PreSaveAction and value is empty. What am I missing?Attachments:
-
November 26, 2019 at 19:00 #27745
Is this in EditForm? – the beforeproperties only reflect the value the field had last time it was saved and not the previous value when editing in the same session.
Alexander
-
November 26, 2019 at 22:19 #27751
Its a New form. Other properties correctly show the fields values.
By “Custom javascript function” you suggect jQuery instead of getFieldValue? -
November 26, 2019 at 23:30 #27754
In NewForm, the object will contain the default values that the form is loaded with, but in general it is supposed used to keep track of the values that the form had when it loaded, and not the changes made withing the current session.
If you can explain what you are trying to do I’ll see if I can help you with a code snippet.
Alexander
-
December 3, 2019 at 16:19 #27815
Alex, other fields show defined values when checked in dffs_PreSaveAction. Only multi- lookup is empty. Single- lookup field shows correct value as well. Feels like a bug.
I hope theres a way to make a Rule work with multi- lookup field. If not, I need to check multi- lookup values before submitting the form and populate a hidden field based on selection. -
December 4, 2019 at 20:55 #27838
I’m still not 100% sure I follow. If you are in NewForm you cannot really have a “beforeproperty” of any fields other than the ones that have a default value set in the list settings for that field (and a required single lookup field has the first item selected by default when it is set to required in the list settings).
What is it you try to do exactly? – if you give me some more details I’m sure I can find a solution for you.
Alexander
-
December 12, 2019 at 16:32 #27989
Alex,
The NEW form has a lookup field with multiple values. I need to read its value BEFORE form is submitted. Please suggest approach. So far all the spjs.dffs objects I looked have empty value:
getFieldValue()
afterProperties
beforeProperties -
December 13, 2019 at 17:01 #28004
You can use a snippet like this:
var arr = []; jQuery("#dffs_MultiLookup select:last option").each(function(i,o){ arr.push(jQuery(o).text()); }); // arr is an array of all the text values selected in the multilookup
Replace MultiLookup with your field name.
Alexander
-
February 25, 2020 at 16:46 #28867
How do you asses that there has been a/any change for multi-lookup field?
I have my JS for what I want to do but I can’t seem to get it to run after a change has occurred. I need it for both New and Edit. Since its not in the rules I’m not sure how I can trigger it.
-
February 25, 2020 at 19:49 #28873
You can use something like this:
String(getFieldValue("MultiLookup")) !== String(spjs.dffs.beforeProperties.MultiLookup);
This code compares the current value of a field called “MultiLookup” (using getFieldValue) with the last saved value (using spjs.dffs.beforeProperties) and compares them.
When do you need to run this code? – if it is pre save you can add it to a function called dffs_PreSaveAction like this:
function dffs_PreSaveAction(){ if(String(getFieldValue("MultiLookup")) !== String(spjs.dffs.beforeProperties.MultiLookup)){ // Do something } return true; }
Alexander
-
-
AuthorPosts
- You must be logged in to reply to this topic.