Das Notes Forum

Domino 9 und frühere Versionen => ND6: Entwicklung => Thema gestartet von: judicious am 28.11.05 - 09:42:59

Titel: Feld mit Roles
Beitrag von: judicious am 28.11.05 - 09:42:59
Guten Morgen
Leider bin ich noch nicht so weit mit meinem Wissen um das folgende Problem selber zu lösen. Ich gebe mir aber Mühe, doch hier komme ich echt nicht weiter.
Also ich habe ein Feld und mehrere Roles. Jetzt möchte ich das wenn ein User in zwei Roles drin ist zb Gruppe1 und Gruppe2, dann soll er die Auswahl haben, Gruppe1 oder Gruppe2. Ist er jedoch nur in einer Role drin, zb Gruppe4, dann soll direkt stehen Gruppe4.
Wie löse ich sowas am besten?
Titel: Re: Feld mit Roles
Beitrag von: Axel am 28.11.05 - 09:50:04
Hi,

schau dir mal die Formel-Funktion @UserRoles an. Die liefert eine Liste mit allen Rollen, die dem User zugeordnet sind. Als Feld würde ich ein Dialogfeld nehmen.

Axel
Titel: Re: Feld mit Roles
Beitrag von: judicious am 28.11.05 - 10:11:01
sowas habe ich schon probiert. Doch es nimmt immer einfach den ersten Wert, ich bekomme gar nie eine Auswahl, auch wenn ich in mehr als einer Gruppe bin:
REM {This source defines the Business Unit from the Userroles};
@If(
      @IsNewDoc; @If(
                  @Contains(@UserRoles;"[BUA]");"A";
                  @Contains(@UserRoles;"[BUD]");"D";
                  @Contains(@UserRoles;"[BUE]");"E";
                  @Contains(@UserRoles;"[BUG]");"G";
                  @Contains(@UserRoles;"[BUR]");"R";
            ""
            );
      tmp_txBusinessUnit
)
Titel: Re: Feld mit Roles
Beitrag von: Axel am 28.11.05 - 10:40:15
Hi,

das kann auch so nicht gehen. Für eine Auswahl brauchst du eine Liste.

Versuch's mal so:

REM {This source defines the Business Unit from the Userroles};
value := "";
@If(
                  @Contains(@UserRoles;"[BUA]");@Set("value";"A");
                  @Contains(@UserRoles;"[BUD]");@Set("value";value + " D");
                  @Contains(@UserRoles;"[BUE]");@Set("value";value + " E");
                  @Contains(@UserRoles;"[BUG]");@Set("value";value + " G");
                  @Contains(@UserRoles;"[BUR]");@Set("value";value + " R");
       ""
      );

@If(@IsNewDoc; @Trim(@Explode(value; " ")); tmp_txBusinessUnit)


Axel
Titel: Re: Feld mit Roles
Beitrag von: koehlerbv am 28.11.05 - 10:53:28
Das wird so auch nix. Hinter dem @If wird immer nur erste zutreffende Bedingung ausgeführt.

Es müsste also heissen:
value1 := @If (@Contains(@UserRoles;"[BUA]");"A"; "");
value2 := @If (@Contains(@UserRoles;"[BUD]"); value1 + " D"; value1);
usw. (das ist die Notation, die auch zu R5 kompatibel ist).

Der Rest der Formel ist entsprechend anzupassen.

Bernhard
Titel: Re: Feld mit Roles
Beitrag von: judicious am 28.11.05 - 11:02:54
hmmm, das klappt auch nicht wirklich, die Box bleibt einfach weiss. Mache ich mit dem Code unten was falsch?

REM {This source defines the Business Unit from the Userroles};
value := "";

value1 := @If (@Contains(@UserRoles;"[BUA]");"A"; "");
value2 := @If (@Contains(@UserRoles;"[BUD]"); value1 + " D"; value1);

@If(@IsNewDoc; @Trim(@Explode(value; " ")); tmp_txBusinessUnit)
Titel: Re: Feld mit Roles
Beitrag von: koehlerbv am 28.11.05 - 11:06:26
Es passiert doch genau das, was Du angeordnet hast:
value := "";
...
@If(@IsNewDoc; @Trim(@Explode(value; " ")); tmp_txBusinessUnit)

value ist leer ...

Bernhard
Titel: Re: Feld mit Roles
Beitrag von: judicious am 28.11.05 - 11:08:51
?? verstehe ich nicht und wie bringe ich jetzt die werte von oben in die listbox?
Titel: Re: Feld mit Roles
Beitrag von: koehlerbv am 28.11.05 - 11:10:41
Wenn Du das nicht verstehst, haben wir ein grosses Problem, Dir zu helfen.
Titel: Re: Feld mit Roles
Beitrag von: judicious am 28.11.05 - 11:13:23
Also ich habe es jetzt so:
REM {This source defines the Business Unit from the Userroles};
value := "";
@If(
                  @If (@Contains(@UserRoles;"[BUA]");"A"; "");
                  @If (@Contains(@UserRoles;"[BUD]"); value + " D"; value);
      );

@If(@IsNewDoc; @Trim(@Explode(value; " ")); tmp_txBusinessUnit)
Titel: Re: Feld mit Roles
Beitrag von: Axel am 28.11.05 - 11:14:46
So könnte es gehen:

REM {This source defines the Business Unit from the Userroles};
value := "";

@If (@Contains(@UserRoles;"[BUA]");@Set("value"; "A"); "");
@If (@Contains(@UserRoles;"[BUD]"); @Set("value"; value + " D"; "");
...

@If(@IsNewDoc; @Trim(@Explode(value; " ")); tmp_txBusinessUnit)


@Bernhard
Klar, du hast recht. Ich hatte nicht daran gedacht, dass bei der ersten Übereinstimmung der Rest nicht mehr beachtet wird. Ein komfortablere Lösung wären die neuen Schleifenbefehle.


Axel
Titel: Re: Feld mit Roles
Beitrag von: judicious am 28.11.05 - 11:20:32
Das klappt. Bei dir hat sich noch ein kleiner Fehler eingeschlichen!
REM {This source defines the Business Unit from the Userroles};
value := "";

@If (@Contains(@UserRoles;"[BUA]");@Set("value"; "A"); "");
@If (@Contains(@UserRoles;"[BUD]"); @Set("value"; value + " D"); "");

@If(@IsNewDoc; @Trim(@Explode(value; " ")); txBusinessUnit)

Die fehlte bei dir. Aber jetzt klappt es wunderbar :) Danke viel mal
Titel: Re: Feld mit Roles
Beitrag von: Thomas Schulte am 28.11.05 - 11:45:25
Wenn das jeweils immer der letzte Buchstabe eine Rolle ist der die Zugehörigkeit definiert, dann kannst du das auch so machen:
_introles := @UserRoles;
_introleslist := @Explode(_introles;" ");
_introleslasttwo := @Right(_introlesList;2);
_introleslastletter := @Left(_introlesLastTwo;1);

@If(@IsNewDoc; _introleslastletter; txBusinessUnit)

Damit fällt nämlich der ganze Zirkus der Änderung wenn neue Units dazukommen weg.

Alternativ zu @Right und @Left würde auch
_introles := @UserRoles;
_introleslist := @Explode(_introles;" ");
_introleslastletter := @MiddleBack( _introleslist ; 2 ; -1 );
funktionieren
Titel: Re: Feld mit Roles
Beitrag von: judicious am 16.12.05 - 15:14:40
Hallo zusammen, bei dem Problem habe ich nun ein weiteres!

REM {This source defines the Business Unit from the Userroles};
value := "";

@If (@Contains(@UserRoles;"[BUA]");@Set("value"; "A"); "");
@If (@Contains(@UserRoles;"[BUD]"); @Set("value"; value + " D"); "");
@If (@Contains(@UserRoles;"[BUE]"); @Set("value"; value + " E"); "");
@If (@Contains(@UserRoles;"[BUG]"); @Set("value"; value + " G"); "");
@If (@Contains(@UserRoles;"[BUR20]"); @Set("value"; value + " R20"); "");
@If (@Contains(@UserRoles;"[BUR40]"); @Set("value"; value + " R40"); "");
@If (@Contains(@UserRoles;"[BURPEAK]"); @Set("value"; value + " RPEAK"); "");

@If(@IsNewDoc; @Trim(@Explode(value; " ")); txBusinessUnit)

Wenn ich ein Dokument jetzt bearbeiten will, dann kann ich immer nur noch RPEAK auswählen. Obwohl ich in allen Gruppen drin bin und ich das Dokument erstellt habe!