Opinions & Help w/Complicated EditRights formula

Hello All

I am working on a editrights field

The following works;
@Unique (@Trim ( "[PDIADMIN]" :"[Coordinator]":@If (FormStatus = "NEW" | FormStatus = "DRA" ;

RequesterName ; FormStatus = "MAN" ;author:reviewer; FormStatus = "REV" ; RequesterName: Author :

RevrName:Coordinator ; FormStatus = "APP" ; RequesterName: Author : ApprName; FormStatus = "DFT"

;RequesterName: Author : LDrafter: ADrafter ; FormStatus = "DFT2" ;LDrafter : ADrafter ; FormStatus =

"RAP";RequesterName: Author : Coordinator; FormStatus =

"WREV":"AREJ":"DAP":"AREV":"RREJ";RequesterName: Author ;FormStatus = "OMIS" ; "[OMIS]" : Author

;FormStatus = "DRW" ; Author : Coordinator ; FormStatus= "CLO"; "NoAccess" ; "NoAccess")))

I have three fields (approver_4, approver_5, approver_6)that need to be added on the form where all

three could = None, two could contain info or one could contain info.

Based on the value of these fields Roles would be assigned.

FormStatus is set depending on the where the document is in the workflow(see above)

All three fields  would be using the sames Roles list.Is there a better way to construct this formula
other than adding what I have below to the above editrights formula

FormStatus = "APP" & approver_4 = "Assembly-Engine"; "[AE1]" : FormStatus = "APP" & approver_4 =

"Assembly-Rotor"; "[AR1]" : FormStatus = "APP"& approver_4 = "Forming-Component-1"; "[FC1]" :

FormStatus = "APP"& approver_4 = "Forming-Component-2"; "[FC2]" : FormStatus = "APP"& approver_4 =

"Forming-Combustion"; "[FC3]" : FormStatus = "APP"& approver_4 = "Forming-Blades&Vanes"; "[FB1]" :
FormStatus = "APP"& approver_4 = "Forming-Details-1"; "[FD1]" : FormStatus = "APP"& approver_4 =

"Forming-Diaphragm-2"; "[FD2]" :

FormStatus = "APP" & approver_5 = "Assembly-Engine"; "[AE1]" : FormStatus = "APP" & approver_5 =

"Assembly-Rotor"; "[AR1]" : FormStatus = "APP"& approver_5 = "Forming-Component-1"; "[FC1]" :

FormStatus = "APP"& approver_5 = "Forming-Component-2"; "[FC2]" : FormStatus = "APP"& approver_5 =

"Forming-Combustion"; "[FC3]" : FormStatus = "APP"& approver_5 = "Forming-Blades&Vanes"; "[FB1]" :
FormStatus = "APP"& approver_5 = "Forming-Details-1"; "[FD1]" : FormStatus = "APP"& approver_5 =

"Forming-Diaphragm-2"; "[FD2]" :

FormStatus = "APP" & approver_6 = "Assembly-Engine"; "[AE1]" : FormStatus = "APP" & approver_6 =

"Assembly-Rotor"; "[AR1]" : FormStatus = "APP"& approver_6 = "Forming-Component-1"; "[FC1]" :

FormStatus = "APP"& approver_6 = "Forming-Component-2"; "[FC2]" : FormStatus = "APP"& approver_6 =

"Forming-Combustion"; "[FC3]" : FormStatus = "APP"& approver_6 = "Forming-Blades&Vanes"; "[FB1]" :
FormStatus = "APP"& approver_6 = "Forming-Details-1"; "[FD1]" : FormStatus = "APP"& approver_6 =

"Forming-Diaphragm-2"; "[FD2]" ;


James E Wood
Who is Participating?
HemanthaKumarConnect With a Mentor Commented:
And elegantly like this
@if(FormStatus = "APP"; ""; @Return(0));

@if(@IsMember("Assembly-Engine" ;approver_4:approver_5:approver_6) ; "[AE1]"; ""):
@if(@IsMember("Assembly-Rotor" ;approver_4:approver_5:approver_6); "[AR1]"; "") :
@if(@IsMember("Forming-Component-1" ;approver_4:approver_5:approver_6); "[FC1]"; "") :
@if(@IsMember("Forming-Component-2" ;approver_4:approver_5:approver_6); "[FC2]"; "") :
@If(@IsMember("Forming-Combustion" ;approver_4:approver_5:approver_6); "[FC3]";"") :
@if(@IsMember("Forming-Blades&Vanes";approver_4:approver_5:approver_6); "[FB1]"; "") :
@if(@IsMember("Forming-Details-1";approver_4:approver_5:approver_6); "[FD1]"; "") :
@if(@IsMember("Forming-Diaphragm-2";approver_4:approver_5:approver_6); "[FD2]"; "")
well James, forgive me, I don't have the time to break down that huge formula right now and attempt to re write it.  What I would do, if it were me, is break it from one giant complex test into a bunch of seperate tests.


name1 := @If( condition ; "NameValue" ; "");
name2 := @If( condition ; "NameValue" ; "");
name100 := @If( condition ; "NameValue" ; "");

then, you have a list of valid names, interspursed with "" null strings.   Use @Trim to get rid of the null strings, and you have your list.

final := @Trim(name1: name2: ... :name100);

the good part of this is you can quickly see and change the consditions for any specific name in your list.
It can also be written like this

@if(FormStatus = "APP"; ""; @Return(0));

@if(approver_4 = "Assembly-Engine" | approver_5 = "Assembly-Engine" | approver_6 = "Assembly-Engine" ; "[AE1]"; ""):
@if(approver_4 = "Assembly-Rotor" | approver_5 = "Assembly-Rotor" | approver_6 = "Assembly-Rotor"; "[AR1]"; "") :
@if(approver_4 = "Forming-Component-1" | approver_5 = "Forming-Component-1"| approver_6 = "Forming-Component-1"; "[FC1]"; "") :
@if(approver_4 = "Forming-Component-2"| approver_5 = "Forming-Component-2" | approver_6 = "Forming-Component-2"; "[FC2]"; "") :
@If(approver_4 = "Forming-Combustion"| approver_5 = "Forming-Combustion"| approver_6 = "Forming-Combustion"; "[FC3]";"") :
@if(approver_4 = "Forming-Blades&Vanes"|approver_5 = "Forming-Blades&Vanes"|approver_6 = "Forming-Blades&Vanes"; "[FB1]"; "") :
@if(approver_4 = "Forming-Details-1"|approver_5 = "Forming-Details-1"|approver_6 = "Forming-Details-1"; "[FD1]"; "") :
@if(approver_4 = "Forming-Diaphragm-2"|approver_5 = "Forming-Diaphragm-2"|approver_6 = "Forming-Diaphragm-2"; "[FD2]"; "")

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

If I have copied bits of your code correctly, and haven't overread anything, It is possible.
The basis for approver_4, approver_5 and approver_6 is always the same: they (can) contain the same approvers and always get translated to the same roles.
You could simplify it into:

ApprLst :=
   "Assembly-Engine" :
   "Assembly-Rotor" :
   "Forming-Component-1" :
   "Forming-Component-2" :
   "Forming-Combustion" :
   "Forming-Blades&Vanes" :
   "Forming-Details-1" :

RoleLst :=
   "[AE1]" :
   "[AR1]" :
   "[FC1]" :
   "[FC2]" :
   "[FC3]" :
   "[FB1]" :
   "[FD1]" :

App4 :=
App5 :=

App6 :=

   FormStatus = "APP";
   @Unique(@Trim(App4 : App5 : App6));

Beware that ApprLst and RoleLst form a 1:1 list!
That's because I don't like redundancies....

And to improve that, forget about App4, App5 and App6:

     approver_4 : approver_5 : approver_6;
Add this line before your other @Unique:
approvers:= @Unique (@Trim ( approver_4 : approver_5 : approver_6));
This will combine the values for those approver fields into one field to test.
Now add this to the end of your existing if statement:

FormStatus = "APP" ;
  IF( @contains (approvers; "Assembly-Engine"); "[AE1]" ;
    @contains (approvers; "Assembly-Rotor"); "[AR1]";
    @contains (approvers; "Forming-Component-1"); "[FC1]" ;
    @contains (approvers; "Forming-Component-2"; "[FC2]" ;
    @contains (approvers; "Forming-Combustion"); "[FC3]" ;
    @contains (approvers; "Forming-Blades&Vanes"; "[FB1]" ;
    @contains (approvers; "Forming-Details-1"); "[FD1]" ;
    @contains (approvers; "Forming-Diaphragm-2"); "[FD2]" ;

This is interesting...
imjameswAuthor Commented:
I have to say this has generated some excellent ideas. I am evaluating a few of them. Thanks to all who participated. This seem to be the great thing about Notes, so many ways to reach a goal.

Best Regards

....and we haven't even discussed any lotusscript ways yet!
imjameswAuthor Commented:
That had occured to me

Another variation is I would like to be able to use something like the above in a Hidewhen for a button
Each approver have their own accept button that is visible only under certain statuses of the form and only to the person listed in the approver_* field.
Something like
StatusRev != "Complete" | StatusD != "Drafting Complete" | (@IsNotMember(@Name([CN]; @UserName); Approver_3)) |  AppStat_3 = "Approval Completed"

What I need it to is to only show to the correct role
so if the approver field contains Assembly-Engine then AE1 etc...

I don't think I have a complete image of the full scale problem here.
Does it help if I say that I would compare the approvers field with @UserNamesList to start with? It would save you checking a lot of roles groups and the username separately.
Here is an idea that may help.

Name: * Venkatesh Padmanabhan
Code Title: * Hide Formulas Optimization
Description: *
Suppose you have say some 50 fields in your form and they can be
grouped. Say some 10 fields should be visible under a particular
condition, another 7 and some other condition etc....
Instead writing the entire code directly in the individual fields,
we can create some computed hidden fields and write the Hide
formula there. These fields will contain either 1 or 0. Now use this fieldname in the hideformulas. This is a very
efficient way of writing a Hide formulas.
Suppose if the Hide formula has to be changes then it can
be changed at a single place. If Hide formulas contain complex
formulas like @DbLookup then instead of doing a Lookup on all
the fields which contain these Hide formulas, this (Dblookup)
will be calculated only once.

I hope this helps.

imjameswAuthor Commented:
Thanx Again

You were right there were some excellent ideas

All Courses

From novice to tech pro — start learning today.