GetValueListDisplayValue used in calculations

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

GetValueListDisplayValue used in calculations

Postby e.valstar » Tue May 30, 2017 9:02 pm

HI,
I try to get a value back in calculations method of a datasource by using application.getValueListDisplayValue.

Used code:
Code: Select all
function show_incoterms() {
   if (incoterms) {    //{Number}
      return application.getValueListDisplayValue("incoterms2010",incoterms);
   }
   return null;
}


The valuelist "incoterms2010" looks like:
Code: Select all
EXW|%%scopes.constants.LEVERING_INCOTERMS.exw%%
CFA|%%scopes.constants.LEVERING_INCOTERMS.cfa%%

etc.

and:
Code: Select all
var LEVERING_INCOTERMS = {
   exw: 1,
   cfa: 2,

etc.

This doesn't work!
But when the valuelist look like:
Code: Select all
EXW (ophalen)|1
CFA (naar kweker / loods - ALLEEN over land)|2

etc.
It works fine. But I don't want a code on 2 places. :?
How can I avoid this? What do I wrong?

Thanks al ready.
e.valstar
 
Posts: 8
Joined: Mon Nov 17, 2014 9:52 pm

Re: GetValueListDisplayValue used in calculations

Postby Bernd.N » Wed May 31, 2017 12:54 am

I can not tell why this does not work, though an alternative solution would be to
a) store the incoterm codes themself (e.g. "EXW") instead of just a number 1,2,3...
b) use i18n functions to translate the code for the users into an explanation
That concept could be used for valuelists to support listboxes, too.

Advantage would be that you see the speaking codes in the database table, and can support users with other languages.
Bernd Korthaus
LinkedIn
Servoy 7.4.9 SC postgreSQL 9.4.11 Windows 10 Pro
User avatar
Bernd.N
 
Posts: 472
Joined: Mon Oct 21, 2013 5:57 pm
Location: Langenhorn, North Friesland, Germany

Re: GetValueListDisplayValue used in calculations

Postby Bernd.N » Wed May 31, 2017 8:32 am

Regarding your initial problem, I could imagine that
Code: Select all
EXW|%%scopes.constants.LEVERING_INCOTERMS.exw%%

does not work because the %%-replacement-mechanism does not work in that context.
Instead Servoy takes that string literally.

You could also use
Code: Select all
EXW (ophalen)|EXW
CFA (naar kweker / loods - ALLEEN over land)|CFA

as then you do not have to remember what 1 and 2 stand for.
Bernd Korthaus
LinkedIn
Servoy 7.4.9 SC postgreSQL 9.4.11 Windows 10 Pro
User avatar
Bernd.N
 
Posts: 472
Joined: Mon Oct 21, 2013 5:57 pm
Location: Langenhorn, North Friesland, Germany

Re: GetValueListDisplayValue used in calculations

Postby e.valstar » Mon Jun 05, 2017 7:56 pm

Thanks Bernd,
Unfortunaly less flexibel as how I wanted, but at least this works.
e.valstar
 
Posts: 8
Joined: Mon Nov 17, 2014 9:52 pm

Re: GetValueListDisplayValue used in calculations

Postby sean » Tue Jun 06, 2017 4:29 am

There is a case related to this.
https://support.servoy.com/browse/SVY-11103
Fixed in 8.1.4

Not sure if this is the the same problem you experience?
Software Engineer
Servoy USA
sean
 
Posts: 85
Joined: Mon May 21, 2007 6:26 pm
Location: USA


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 10 guests