Cascading dropdowns issue
-
- Posts: 9
- Joined: Thu Mar 23, 2017
Hi,
I'm new to Forms Designer and my company is testing this out. On our SP2013 site, I have created a list, let's call it 'Test Tasks'. In this list, I have two dropdowns, one for 'Customer' and one for 'Project'. These are both lookup columns to respectively named lists. In the 'Projects' list there is a link to 'Customer'.
What I'm trying to accomplish is:
When creating a new item in the 'Test Tasks' list, I would like to select a Customer and have that filter the Projects dropdown. I believe this is what you call 'Cascading Dropdowns'. I have tried to use the method described here: https://spform.com/cross-site-lookup/ca ... office-365, but I just can't get it to work. This is what I have so far:
I don't think this script is entirely correct, but I'm not sure as how to improve it. Also, if I am on the 'new form' for 'Test Tasks' and I F12 in the browser I see this an error saying 'Uncaught SyntaxError: Unexpected Token '('' -> referring to the first '(' after 'function'.
This feature is a great incentive for us to buy this tool, but we need to know beforehand if it will even work. Thanks in advance for your efforts!
Kind regards
I'm new to Forms Designer and my company is testing this out. On our SP2013 site, I have created a list, let's call it 'Test Tasks'. In this list, I have two dropdowns, one for 'Customer' and one for 'Project'. These are both lookup columns to respectively named lists. In the 'Projects' list there is a link to 'Customer'.
What I'm trying to accomplish is:
When creating a new item in the 'Test Tasks' list, I would like to select a Customer and have that filter the Projects dropdown. I believe this is what you call 'Cascading Dropdowns'. I have tried to use the method described here: https://spform.com/cross-site-lookup/ca ... office-365, but I just can't get it to work. This is what I have so far:
Code: Select all
function (term, page) {
var CustomerId = fd.field('Customer').value();
alert(CustomerId );
if (!CustomerId ) {
CustomerId = 0;
}
if (!term || term.length == 0) {
return "myOwnSPSiteUrl/_api/web/lists('Test task list ID')/items?$select=Id {LookupField},Customer/Id&$orderby=Titleasc&$expand=Customer/Id&$filter=Customer/Id eq " + CustomerId +"$top=10";
}
return "myOwnSPSiteUrl/_api/web/lists('Test Task list ID')/items?$select=Id,Project&$orderby=Project&$filter=startswith(Project, '" + encodeURIComponent(term) + "')&$top=10";
}
This feature is a great incentive for us to buy this tool, but we need to know beforehand if it will even work. Thanks in advance for your efforts!
Kind regards
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
Hi,
Please, try to use the following code:
Do not replace tokens e.g. {WebUrl} and {ListId}, they will be replaced automatically by the app. Also, ensure that the internal name of the 'Customer' field in the Projects list is literally 'Customer'.
Please, try to use the following code:
Code: Select all
function (term, page) {
var CustomerId = fd.field('Customer').value();
alert(CustomerId );
if (!CustomerId ) {
CustomerId = 0;
}
if (!term || term.length == 0) {
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},Customer/Id&$orderby=Created desc&$expand=Customer/Id&$filter=Customer/Id eq " + CustomerId + "&$top=10";
}
return "{WebUrl}/_api/web/lists('{ListId}')/items?$select=Id,{LookupField},Customer/Id&$orderby={LookupField}&$expand=Customer/Id&$filter=startswith({LookupField}, '" + term + "') and Customer/Id eq " + CustomerId + "&$top=10";
}
-
- Posts: 9
- Joined: Thu Mar 23, 2017
Hi Dmitry,
Thank you for your response. I am still experiencing some issues though. This code doesn't seem to be referencing my 'Project' field anywhere, which is the field I actually wish to filter. Furthermore, just putting this function in my JS doesn't do anything, I still have to call it, right? I also had to give the function a name, or you get a 'Syntax error: unexpected token '(' found'.
I step through the code now and I see that it finds a value for Customer, but when the link is returned, nothing visibly happens (no additional errors either). Do you have any clue as to how I could solve this?
Kind regards,
Thank you for your response. I am still experiencing some issues though. This code doesn't seem to be referencing my 'Project' field anywhere, which is the field I actually wish to filter. Furthermore, just putting this function in my JS doesn't do anything, I still have to call it, right? I also had to give the function a name, or you get a 'Syntax error: unexpected token '(' found'.
I step through the code now and I see that it finds a value for Customer, but when the link is returned, nothing visibly happens (no additional errors either). Do you have any clue as to how I could solve this?
Kind regards,
- Dmitry Kozlov
- Site Admin
- Posts: 1524
- Joined: Thu Jun 07, 2012
Hi,
You have to put this code into 'Request items' template of the Project field in the Cross-site Lookup Manager. Replace 'Customer' field with the internal name of the field by which you want to filter results:
https://spform.com/cross-site-lookup/ca ... office-365
If it still does not work, you can purchase an hour of the support service and we will assist you via screen sharing session:
https://spform.com/buy/support-maintenance
You have to put this code into 'Request items' template of the Project field in the Cross-site Lookup Manager. Replace 'Customer' field with the internal name of the field by which you want to filter results:
https://spform.com/cross-site-lookup/ca ... office-365
If it still does not work, you can purchase an hour of the support service and we will assist you via screen sharing session:
https://spform.com/buy/support-maintenance
-
- Information
-
Who is online
Users browsing this forum: No registered users and 2 guests