Home › Forums › Classic DFFS › Using filtered options from REST API in a lookup field
Tagged: DFFS Classic, filtered lookup, Selector id
- This topic has 15 replies, 2 voices, and was last updated 4 months, 1 week ago by Hao Wang.
-
AuthorPosts
-
-
August 17, 2024 at 22:23 #37982
Hi all,
We want to filter out the options in a lookup field in my form. We do not need cascading lookup as the lookup field already has an ID to use as the query criteria to reduce the number of options. We are able to obtain the results from the REST API. However, whenever I want to update the options in the lookup field, the update overwrites the field’s label instead. Anything I did wrong? Thanks.
-
August 18, 2024 at 09:04 #37983
If you can show me the code you use I can have a look at it.
Alexander
-
August 18, 2024 at 12:42 #37984
Thanks. My code worked in the HTML snippet, so I am set for now. However, when I put in the Custom JS, it fails to run for unknown reasons, probably due to the timing issue. When I call the functions, it says they are not defined yet. I tried delay, polling, or window.onload, none worked.
-
August 19, 2024 at 15:16 #37990
Without looking at the code I’m not able to give you any recommendations on how to fix it.
If you can attach the code as a txt-file I’ll take a look.
Alexander
-
August 19, 2024 at 18:52 #37992
Thank you, Alex. I have attached two simple scripts. Neither worked in the Custom JS section, but both work if I include them in an HTML snippet.
For now it works for me but it would be better if we can put them in Custom JS instead of HTML sections.
Hao
-
August 19, 2024 at 18:54 #37993
Here are the scripts in txt files.
Attachments:
-
August 19, 2024 at 20:26 #37998
Thanks, can you also explain how / when you trigger the functions?
Alexander
-
August 19, 2024 at 22:15 #37999
I tried many ways. I tried using button clicks to call functions, entering the function name in a tab that allows me to run on clicking on the tab, and calling the function(s) in the rules “when the form is ready…” They all said that, in one way or another, the functions were not defined or found. There were no logs after I plugged in some console.log inside the scripts. These were when I put the files in the Custom JS and verified the paths were good.
However, the inline editing javascript you wrote ran seamlessly when I put it there. I scratched my head and believed I must have missed something.
Thanks for helping.
-
August 20, 2024 at 15:23 #38005
My first thought is that you had the code wrapped in a block (function or if-statement) so it was not available in the global window namespace, but without seeing your entire custom js code I cannot tell for sure.
In general you can add functions to the Custom JS code editor and call the functions from a button in a HTML section or by calling them from a rule.
Alexander
-
August 20, 2024 at 18:45 #38010
The sample Javascripts I sent you in those Txt files were used as the “entire” custom JS codes, yet we cannot call the functions in them from a button or a rule. You are right; they were not in the global window namespace. We tried to modify the function definition using a window.XXX, it did not work either. Thanks though. Now they are running in my embedded HTML sections, so we are okay with that.
-
August 20, 2024 at 18:46 #38011
I suspect it is the script loading issue, though we handled your inline editing Javascript in the same manner, and they work!
-
August 20, 2024 at 19:35 #38012
I have created a test config that you can import into a list. It will show you how to use the custom js and call one of the functions from a HTML section.
Create a new list with only the title field and install DFFS. Go to the Export, import and restore tab and import the config by copy pasting from the attached file.
Please note that the function will obviously not work in this test list because the target fields are missing.
It looks like my attachment plugin suddenly blocks txt files – trying again with a zip.
Alexander
- This reply was modified 4 months, 1 week ago by Alexander Bautz.
Attachments:
-
August 22, 2024 at 01:31 #38021
Alexander; it is embarrassing that my site now lost the ability for us to create a new list and install the classic DFFS. The column type DFFS Loader by SPJSBlog.com is now missing from my site. Creating a column with that name won’t bring up the configuration I need. Any advice on how I can bring that configuration back? Thanks. Hao
-
August 23, 2024 at 21:32 #38022
Alexander, thanks. I recreated the installer, installed DFFS on a new list, and then imported your config. How you configured it works by including the script in the editor window of the Custom JS tab.
Instead of pasting the JavaScript into the Custom JS editor window, I used the text area above to include my script as a file, and the file path verified OK. It stopped working.
I included your inline editing script as a file; it works there. I am curious what is going on.
Hao
By the way, how can I recover the production license installed by SP Services? While I tried to recreate the classic installer, the message of the trial period appeared in the configuration window for the new test list. The old lists still work with the production license.
-
August 24, 2024 at 08:40 #38023
Not sure why it did not work when you used a file, but based on the fact that you use the old JSLink installer, I assume you use an older version of DFFS. If you hover over the Enhanced with DFFS link below the form and click the License and version information link you can see the version numbers.
The SP Services license is an OEM license for the core functionality that they deliver. This means you cannot use that license for additional lists that are not part of the package delivered by SP Services.
If you want to use DFFS in additional sites you must purchase a site or site collection license.
Alexander
-
-
August 24, 2024 at 13:54 #38025
Ok. I already bought a site collection license for the modern version of the DFFS. We will rewrite our own app and retire the SP app using the old version of the DFFS soon. You showed me how to put the JavaScript in the Custom JS editor window, which is better than putting it in the HTML snippet. We had thought that Custom JS did not work at all. Thanks.
-
-
AuthorPosts
- You must be logged in to reply to this topic.