outra9e
29th August 2002, 11:28
Hi all.

We have 9 companies in our Baan environment. I have a field on a session which is an enumerated field and I want the default value of the field to be dependent on what company the user has logged in to.

Any ideas?

Idon't know if this is possible just wondered.

Cheers

morpheus
29th August 2002, 13:16
Hello,
Don't know about any standard feature, but you can use IF conditions...

outra9e
29th August 2002, 13:17
Want I guess I need to know, is if there is a field that denotes what company the user has logged into?

morpheus
29th August 2002, 13:22
Yes, use get.compnr(). This will help you.

outra9e
29th August 2002, 14:09
so ....

|***************************
field tdsls901.regn:
before.input:
get.compnr()
if tc.cono = 501 then
tdsls901.regn = tdsls.nregn.TEE
endif
if tc.cono = 509 then
tdsls901.regn = tdsls.nregn.TEY
endif
if tc.cono = 502 then
tdsls901.regn = tdsls.nregn.TEF
endif
if tc.cono = 503 then
tdsls901.regn = tdsls.nregn.TED
endif
if tc.cono = 505 then
tdsls901.regn = tdsls.nregn.TEI
endif
|********************************

Would this work do you think?

CHeers

FransG
29th August 2002, 14:14
Put the output of get.compnr() into a variable.

comp.number = get.compnr()
on case comp.number
case 501:
tdsls901.regn = tdsls.nregn.TEE
break
case 502:
|etc...
endcase

This will work...

outra9e
29th August 2002, 14:49
Frans

Thanks for this, how does a case fit into the script structure?

Do I need to declare anything, or do I just put this in the field section, after a Befroe.Input?

Cheers

FransG
29th August 2002, 15:09
You can put it in the before.input section; but you can also put it in a function and call the function from the before.input section.
At least this works fine in BaanERP - I'm not 100% sure about Baan IV - just try it.

There is no declaration required for the case statement. Don't forget the break statement.


field.tdsls901.regn:
before.input:
on case comp.number
case 501:
tdsls901.regn = tdsls.nregn.TEE
break
case 502:
...
break
endcase

OmeLuuk
29th August 2002, 15:20
"Forget about the case"
in the past I have been told that the Baan compiler breaks up case statements in separate if then statements... ;)

FransG
29th August 2002, 15:28
Come on, give me a break. In the end all code end up in one's and zero's.....

10011110010000100001000111101001000101001110 ;) ;) ;)

Armando_Rod2000
29th August 2002, 15:38
a technical solution consist in create a parameter's table when u gonna to define the company and the enumarated value. Yoy can make a function that get the enumarated values from the



table:field.tdsls901.regn:
before.input:
tdsls901.regn = get.parameter.value(get.compnr())

|****************** function section
function domain XXXXXXX get.parameter.value(domain tccomp comp)
{
select TABLEYYY.*
from TABLEYY
where TABLEYY.comp = comp
selectdo
return(tableYYY.enumerate.value)
endselect
return(0) ==> Here return a default value. Any value u want!!!
}


********** The table
The table must have 2 camps (comp and enumerated.value)

********** Other coments
You can make a library for future function's uses at other scripts ;)

outra9e
29th August 2002, 16:46
Frans

I tried this...


******************************************
field.tdsls901.regn:
before.input:
on case get.compnr()
case 501:
tdsls901.nregn = tdsls.regn.TEE
break
case 502:
tdsls901.nregn = tdsls.regn.TED
break
case 503:
tdsls901.nregn = tdsls.regn.TEF
break
case 504:
tdsls901.nregn = tdsls.regn.TEE
break
case 505:
tdsls901.nregn = tdsls.regn.TEI
break
case 506:
tdsls901.nregn = tdsls.regn.TEE
break
case 507:
tdsls901.nregn = tdsls.regn.TER
break
case 508:
tdsls901.nregn = tdsls.regn.TEE
break
case 509:
tdsls901.nregn = tdsls.regn.TEY
break
endcase
******************************************

why can't I just use the get.compnr() function as the case?
I presume that this is the reason why this did not work...

Armando

I had a look at your post but I am afraid I do not quite understand. Im still a bit new qith development!

Cheers guys :D

FransG
29th August 2002, 17:00
Andy,

This worked for me. What happens in debug mode? Have you checked. What happens if you replace your case statement with the following? Do you get a message with the company number?


on case get.compnr()
case 501:
message("501")
break
case 502:
message("502")
break
case 503:
message("503")
break
case 504:
message("504")
break
case 505:
message("506")
break
case 506:
message("506")
break
case 507:
message("507")
break
case 508:
message("508")
break
case 509:
message("509")
break
endcase

outra9e
29th August 2002, 18:16
Frans

This may be a really stupid question but where should I be setting the get.compnr() to comp.number variable? and how?

Cheers

outra9e
29th August 2002, 18:19
Frans

I have just tried using the message("501")
bit.

It didnt do anything.

Cheers

outra9e
30th August 2002, 13:13
Hi Frans

Here is what I currently have in my script. I rem'ed out the message lines as they didn't seem to do anything...


*****************************************
field.tdsls901.regn:
before.input:
on case get.compnr()
case 501:
| message("501")
tdsls901.nregn = tdsls.regn.TEE
break
case 502:
| message("501")
tdsls901.nregn = tdsls.regn.TED
break
case 503:
| message("501")
tdsls901.nregn = tdsls.regn.TEF
break
case 504:
| message("501")
tdsls901.nregn = tdsls.regn.TEE
break
case 505:
| message("501")
tdsls901.nregn = tdsls.regn.TEI
break
case 506:
| message("501")
tdsls901.nregn = tdsls.regn.TER
break
case 507:
| message("501")
tdsls901.nregn = tdsls.regn.TEE
break
case 508:
| message("501")
tdsls901.nregn = tdsls.regn.TEE
break
case 509:
| message("501")
tdsls901.nregn = tdsls.regn.TEY
break
endcase
******************************************

Cheers

mark_h
30th August 2002, 14:53
Have you put your code in debug mode? I would like to know what happens when you click into the field. I also notice there is no display("tdsls901.nregn") after the case statement.

Mark

outra9e
30th August 2002, 15:56
field.tdsls901.regn:
before.input:
on case get.compnr()
case 501:
| message("501")
tdsls901.nregn = tdsls.regn.TEE
display("tdsls901.nregn")
break

I have implemented this and run in debug.

It seems to pick up the values, but in debug, as it is an enumerated field it shows in the debug the number instead of the value.

Any ideas?

Cheers

mark_h
30th August 2002, 16:18
Hi Andy,

I am a little confused. Do you want the field to be defaulted when they first start the session? If so instead of using the before.input section I would use the before.display section. Anyway it seems that the code is working and in debug mode I would expect the variable to have the number.


Mark

FransG
2nd September 2002, 10:40
Hi Andy,

I was out of office last friday. Did you make any progress? I get the same feeling as Mark (i.e. confused). In debug mode enum values are reflected as long. These are the constant numbers as defined for the domain.

If you find out where this fails, please inform us.

outra9e
2nd September 2002, 10:43
Hi Frans

I ran the session in debug mode using the following script section...

**********************************************

field.tdsls901.regn:
before.display:
on case get.compnr()
case 501:
| message("501")
tdsls901.nregn = tdsls.regn.TEE
display("tdsls901.nregn")
break
case 502:
| message("501")
tdsls901.nregn = tdsls.regn.TED
display("tdsls901.nregn")
break
case 503:
| message("501")
tdsls901.nregn = tdsls.regn.TEF
display("tdsls901.nregn")
break
case 504:
| message("501")
tdsls901.nregn = tdsls.regn.TEE
display("tdsls901.nregn")
break
case 505:
| message("501")
tdsls901.nregn = tdsls.regn.TEI
display("tdsls901.nregn")
break
case 506:
| message("501")
tdsls901.nregn = tdsls.regn.TER
display("tdsls901.nregn")
break
case 507:
| message("501")
tdsls901.nregn = tdsls.regn.TEE
display("tdsls901.nregn")
break
case 508:
| message("501")
tdsls901.nregn = tdsls.regn.TEE
display("tdsls901.nregn")
break
case 509:
| message("501")
tdsls901.nregn = tdsls.regn.TEY
display("tdsls901.nregn")
break
endcase

*********************************************
Once the scripting has been carried out, if you click the field name in debug, it shows the constant of the value that it should be, however it doesn't display it in the session.

Cheers

FransG
2nd September 2002, 12:13
Andy,

Please check your field names...

field.tdsls901.regn:
before.display:
on case get.compnr()
case 501:
tdsls901.nregn = tdsls.regn.TEE
display("tdsls901.nregn")
break
case 502:
...

outra9e
2nd September 2002, 12:26
Frans

Have made the changes but still no joy.

Any other ideas?

Cheers for all your help

FransG
2nd September 2002, 12:38
If the field defined at your form and the field in your script are the same - then I'm out of options. This must be a table field or an extern declared form field, right?

Sorry. I give up. :(

outra9e
2nd September 2002, 14:02
Frans

Not to worry m8, its not essential, thank you for all your time on this, ill keep playing with it.

Cheers

ulrich.fuchs
2nd September 2002, 14:37
Andy,

try calling function

refresh()

after your case structure. display("..") alone will not be enough to actually update the screen!

Uli

outra9e
2nd September 2002, 14:41
I had the field name wrong, I have changed this and I am now getting this error...

jaapzwaan
2nd September 2002, 14:47
:confused:
What else did you expect? You do a "display(x)" in the before.display if field x.
This will loop indeed, and that's the message you get.

outra9e
2nd September 2002, 14:50
Yes

It is official I am a muppet.

I have changed it to a check.input and it is working fine.

Thanks guys