Trust ID PBCEX logo 300x102

Multiple Objects depending on same script value

5 years 11 months ago
vandenberg
Expert Boarder
Expert Boarder
Posts: 106
More
Topic Author
Multiple Objects depending on same script value #4129
Hello, the following problem occured today and i cant figure it out.

I know how to define a fields color based on some data, and i know how to define a field with tekst in it. But how do i link both of them to the same data without having my script failing?
the following is what we know:

def Lokatie(lok):
s = str(lok)
if s == 'Buys Ballot':
return '#FFFAFF00'
if s == 'De Waard':
return '#FFFFCB00'
else:
return 'White'

This script works to color a field, based on the location

def Lokatie(lok):
s = str(lok)
if s == 'Buys Ballot':
return 'Cambium College Locatie Buys Ballot Courtine 2 5301 DH Zaltbommel'
if s == 'De Waard':
return 'Cambium College Locatie De Waard Oude Bosscheweg 2 5301 LA Zaltbommel'
else:
return 'fout'

This script works to put the adress in a field, based on its location

But how do i put these together in one field of functions without them conflicting with eachother? Based on logic, the field showing the adress also wants to show the color and vice versa?
5 years 11 months ago
Sergio Agostinho
Administrator
Administrator
Posts: 508
More
Multiple Objects depending on same script value #4131
Hi vandenberg,

You need to add one different name to each function, than you can use one for the background property in the Expressions tab and the other to show the correct text in the Content tab.

With best regards
Sergio Agostinho
5 years 11 months ago
vandenberg
Expert Boarder
Expert Boarder
Posts: 106
More
Topic Author
Multiple Objects depending on same script value #4132
Hello Sergio,
I have tried the following:

def Lokatie(lok):
s = str(lok)
if s == 'Buys Ballot':
return '#FFFAFF00'
if s == 'De Waard':
return '#FFFFCB00'
else:
return 'White'

def Lokatie(loka):
s = str(loka)
if s == 'Buys Ballot':
return 'Cambium College Locatie Buys Ballot Courtine 2 5301 DH Zaltbommel'
if s == 'De Waard':
return 'Cambium College Locatie De Waard Oude Bosscheweg 2 5301 LA Zaltbommel'
else:
return 'fout'

I have stated the location in the expressions tab for the text as (loka), and for the background as (lok).
The text is displayed correct now, but i do not have any color displayed on the background, not even White (as i think it should when something is wrong?)

how do i solve this problem?

Ty for you fast reply
5 years 11 months ago
Sergio Agostinho
Administrator
Administrator
Posts: 508
More
Multiple Objects depending on same script value #4133
Hi vandenberg,

You need to change the name of the function and not it's parameter name, like for example def LokatieColor(lok) and def LokatieText(lok)

With best regards
Sergio Agostinho
The following user(s) said Thank You vandenberg
×

Notice

The forum is in read only mode.