For my intended solution, it is essential to set the Site URL dynamically. Sadly, I could not find any documentation or community post. Do you know how to change the site URL with JS?
You can change the List or Library control source site, list and the view with the code:
//set the source site
fd.control('Control1').webUrl = '/sites/MainSite/SubSite';
//set the source list or library
fd.control('Control1').listUrl = 'Lists/List1';
//set the list view by name
fd.control('Control1').viewName = 'All Items';
//set the list view by ID
fd.control('Control1').viewId = 'FEB4302C-617F-4B6B-86F2-9A3F718E4F58';
I beleave you had a typo in your previous post, in the set list or library line .WebUrl ist defined again, i believe it should be:
fd.control('Control1').listUrl = 'Lists/List1';
Anyway I tried to execute the code inside fd.spRendered(function() {} or also inside a button without success (the list remains as initially set):
var dt = fd.control('ListOrLibrary3');
dt.ready(function() {
setRootFolder();
});
function setRootFolder(){
console.log(fd.control('ListOrLibrary3'));
//set the source site
fd.control('ListOrLibrary3').webUrl = '/sites/MainSite/rw-test2';
//set the source list or library
fd.control('ListOrLibrary3').listUrl = 'Lists/test';
//set the list view by name
fd.control('ListOrLibrary3').viewName = 'viewtest'
console.log(fd.control('ListOrLibrary3'));
}
I also tryed to reload the list fd.control('ListOrLibrary3').refresh(); whiteut success.
do you have any idea? i don't get any errors in the console either.
You have a sharp eye! I've updated the code in my post.
The code should work, please try changing only one thing at once, for instance, source list:
fd.spRendered(function() {
var dt = fd.control('ListOrLibrary3');
dt.ready(function() {
//set the source list or library
fd.control('ListOrLibrary3').listUrl = 'Lists/test';
});
});
If that still doesn't work, please check the browser console for errors. Also make sure that you have the latest version of the desktop designer (3.3.2) and the app package (1.1.0).
I use desktop designer (3.3.2) and the app package (1.1.0). I also tried to run the code on a different tenant, empty list etc.. The form also stays the same if I only try to change the library within the same SP Site collection.
Strangely, I don't get any errors in the console; also, no changes are to be found when logging the list. When I use the control to change the frontend (like hiding buttons), it works...
fd.spRendered(function() {
console.log(fd.control('ListOrLibrary2'))
var dt = fd.control('ListOrLibrary2');
dt.ready(function() { //fd.control('ListOrLibrary3').webUrl = '/sites/MainSite/rw-test2';
//set the source list or library
fd.control('ListOrLibrary1').listUrl = 'Lists/test';
});
console.log(fd.control('ListOrLibrary2'))
fd.control('ListOrLibrary2').ready().then(function(dt) {
//set the source list or library
fd.control('ListOrLibrary2').listUrl = 'Lists/test';
//hide Delete on load
dt.buttons[1].visible = false;
dt.buttons[0].visible = false;
});
});
I hope we can make this possible, as it would help me substantially.