question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

choicesByUrl should save raw data

See original GitHub issue

Are you requesting a feature, reporting a bug or asking a question?

question/feature

What is the current behavior?

my original need was a way to fetch remote object prop in order to populate other questions after selecting that object from a dropdown. I managed to do it by a custom asyn func called getRemoteObjectProperty as suggested by your example (which is, by the way, very similar to Expression Trigger)

However, even if that methodology is very useful in general when I use dropdown with choicesByUrl, the remote service often returns array of objects with all their props. Theoretically there shouldn’t be the need to run the second request in order to fetch the desired object and then its prop as SurveyJS already bumped into it while loading choices from remote.

I, actually, also managed to avoid the second request by an hack which I don’t really like:

https://plnkr.co/edit/RhW7K4lislPHOFeQ?preview

I don’t like the following even if it’s clear and works

survey.onLoadChoicesFromServer.add(function(survey,options) {
    options.question.valueObject = options.serverResult
   })

Maybe tying valueObject directly to question is wrong. To avoid this I thought about a native solution that will let me access valueObject prop in the ItemValue class as I know you can add custom prop to itemvalue class doing something like :

Survey.Serializer.addProperty("itemvalue",
        { name: "alpha3Code" }
      );

but this is hardcoded and I was not able to add the whole valueObject prop that will let me simplify the custom function much more:

https://plnkr.co/edit/SCQaTYKhbYJzfSAW (read the comment at line 14)

Is there a way to attach the whole remote object to the selected item value so that I will enable my users to select which prop insert directly by the json model?

thank you

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
tsv2013commented, Jun 19, 2020

I’ve found the issue. Items were copied but originalItem was not. I’ve added unit test and fixed it. Hope this finally makes it work.

0reactions
tsv2013commented, Jul 17, 2020

@masciugo am I right that in display mode you can’t access addiotional parameters for the selected object? As far as i understand in display mode you already have the data you assign to survey. Can you at this moment (probably even on the sever side) obtain the additional parameters you need?

You can use the survey.data in the getSelectedChoiceProp function as data source for the display mode… The first idea 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Refresh the choice returned by ChoicesURL setting in ...
Is there a question method, etc., easy way to force the refresh/re-pull of choices returned by ChoiceURL property in a Dropdown Question?
Read more >
Best Practice: Preserve information: Keep raw data raw
In order to preserve the raw data for future use: Do not make any changes / corrections to the original raw data file;...
Read more >
Saving Raw Data - Measurand Support
You can save a raw ShapeArray (.RSA) data file containing a single reading from the ShapeArray using the Quick Save button. This button...
Read more >
Guideline #2 - Saving the Original
The original must be retained. Cartoon for Guideline2. The raw image data file is an investigator's safety net. Processed images can be compared...
Read more >
Saving images as RAW data| How to use - Sony
You can save adjusted images as RAW data with the same file name as before. Save (overwrite). Display the desired image in Edit....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found