Rule to set lookup field to field that is empty

Home Forums Classic DFFS Rule to set lookup field to field that is empty

Tagged: 

Viewing 4 reply threads
  • Author
    Posts
    • #17661
      Roelof Meijer
      Participant

        Hello all,

        In a list I have implemneted a dropdown functionality with a filter. And that works fine, unless you do not want to make the field empty.

        This is how I did this:

        In a list i have a text field named OpposingPartyLookupWork
        For this field, in the Custom JS tab, I implemented SPJS.lookup. So that a dropdownlist is shown based on items in another list and I implemented a filter on active entries.

        
        

        spjs.lookup.init({
        “fieldToConvertToDropdown”:[“OpposingPartyLookupWork”],
        “listName”:”{907d734b-f46b-4c0d-a9ea-a7eff0eb314c}”, //OpposingPartiesTest
        “listBaseUrl”:”/Sites/010008/”,
        “optTextFieldInternalName”:”Title”,
        “sortFieldName”:”Title”,
        “filterObj”:{
        “on”:true,
        “folder”:””, // Leave empty to search in all folders
        “CAML”:null, // If used, the rest of the filterObj settings are disregarded
        “fin”:”ActiveYN”,
        “isLookup”:false,
        “operator”:”Eq”,
        “filterVal”:”Yes”
        },
        “dropDownDefaultvalue”:”Geen”,
        “addYouOwnValue”:{
        “on”:false,
        “linkText”:”Write your own value”
        },
        “addToExternalList”:{
        “on”:false,
        “customFunction”:null, // Function name as a string. If a function name is supplied, this will be used in stead of the default function. The function will be passed the argument object as a parameter.
        “linkText”:”Add new item”,
        “saveNewItemText”:”Save new item”
        },
        “debug”:false
        });

        
        

        This works fine.

        Now with a rule I copy the selected value in OpposingPartyLookupWork to another field named OpposingPartyTestLookup in the list. This field is actually a SharePoint lookup field to that same list where the dropdown text field OpposingPartyLookupWork got it’s entries from.

        So in this rule I assign (in the “Set field value” section) to field OpposingPartyTestLookup the value of OpposingPartyLookupWork. The rule triggers on OpposingPartyLookupWork field change.

        This works fine as well. Now i have implemented a lookup functionality for a lookup field with a filter in the values shown in the dropdown menu (only active entries can be selected). Great.

        But to my disappointment this does not work if I want choose an empty value “Geen” in my case. For some reason “Set field value” does not work with empty values. Is there a way to work around this?
        Thanks!

      • #17663
        Roelof Meijer
        Participant

          DFFS frontend 4.4.2.5 Backend v4.4.2.5|CSS version: 4.18 / 4.18|spjs-utility version: 1.27

        • #17678
          Alexander Bautz
          Keymaster

            I’m not 100% sure I understand. Are you selecting a “empty” value in the dropdown, and have a rule triggering on this change that sets the lookup field to the same value (empty string)?

            Are you using the “Set field value” section and leaving the “Value” field empty?

            If this is correct, and it doesn’t work, I’ll look into it and see if I can fix it or make a custom function workaround.

            PS: If the lookup column is required you cannot clear the value – are you able to do it manually in the lookup column?

            Alexander

          • #17693
            Roelof Meijer
            Participant

              Yes, I’m selecting the empty value, (in my case in the dropdown “Geen”, see the spjs.lookup.init parameter). This results in an empty string for the field OpposingPartyLookupWork, but the lookup field OpposingPartyTestLookup remains unchanged (only if the field OpposingPartyLookupWork is empty, otherwise it works fine). And yes, I am using the “Set field value” section and setting the field to the value of {OpposingPartyLookupWork} . And the lookup column is not a required field. Manually I am able to make this field empty.

            • #17734
              Alexander Bautz
              Keymaster

                Hi,
                I was finally able to test this, and it’s working in my setup now, but I might have fixed this issue in an updated version of spjs-utility.js.

                Please try updating DFFS to the latest version, or try changing the SPJS-utlity.js version to the one found in the plugins folder in the latest DFFS package.

                Alexander

            Viewing 4 reply threads
            • You must be logged in to reply to this topic.