Page 1 of 1

Cascading dropdowns issue

Posted: 23 Mar 2017
by jimhugelier
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:

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";
 }
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

Re: Cascading dropdowns issue

Posted: 24 Mar 2017
by Dmitry Kozlov
Hi,
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";
}
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'.

Re: Cascading dropdowns issue

Posted: 27 Mar 2017
by jimhugelier
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,

Re: Cascading dropdowns issue

Posted: 28 Mar 2017
by Dmitry Kozlov
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