Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

JavaScript Async Method call on the OnChange event of a lookup

$
0
0

Hello,

I try to fill dynamically a lookup-multi field by selecting a value in a dropdownlist based on a lookup field.

I recreated the onchange event of my dropdowlist by using this code :

 lookupElement.onchange = function () { OnFormationChanged() };

When a user select an element in the dropdownlist, "OnFormationChanged" event run an Async method who retrieve elements joined with the selected element in the dropdownlist lookup.

This part works fine, it automatically refresh the multi lookup field but when i save my custom page I got the error :

Value does not fall within expected range

When I do alert in the OnFormationChanged, it retrieve me for example '0' in the onChange event and '3' in the Asynch event as you can see in this screenshot :


I deduced that the save event method take a wrong result.

For example :

A : If I select in the lookup dropdownlist an element with no attached result in the multi lookup, I will have '0' in the "OnFormationChanged" method and '0' in the "OnQuerySucceeded" method and the multilookup will be empty.

B : If NOW I select in the lookup dropdownlist an element with results in the multi lookup, I will have '0' in the "OnFormationChanged" method and '3' in the OnQuerySucceeded" method and the multilookup will be filled.

But when I save the custom page I will have the error : Value does not fall within expected range as if async result was not recognized by the save button. 

Something seems not to be set correctly.Could you give me a way to resolve this issue ?

DkPoo.








Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>