@IsNotMember is not working in my Application

Hello All,

I have a approval form, which is filled by Requester for certain materials. After filling all the required fields. The mail is sent to Manager for Approval.

But my concern is that, only Manager has to approve the form, other than any one who tries to hit approve button, it has to prompt “You are not Authorized”.

I have tried below code but it is not working.

Can any one help me in correcting the below code :

Field : Button

@If(@IsNotMember(@Name([CN]; @UserName); Approver);@Failure(@Prompt([Ok]; “NOT Signed”; “You are not listed in Authorized.”));

@Do(@SetField(“Result”;“Approved”);@Do(@SetField(“Status”; “Draft”); (@SetField(“UpDateApproved”; @Name([CN];@UserName) + " on " + @Text(@Now)))));

@If(doc_type =“Materials”;@Success;@MailSend(@Unique(CreatedBy);“”; “”; “Status of Submitted Materials"This Materials has been Approved by the Local Team Leader & sent for Manager for approval.”; “”; [IncludeDoclink]));

@If(doc_type =“Materials”;@Success;@MailSend(@Unique(mailTo) ;“”; “”; “Need Approval”; “This Material has been Approved by the Local Team Leader & need your approval.”; “”; [IncludeDoclink]));

@If(doc_type =“Tools”:“Software”:“Hardware”;@Success;@MailSend(@Unique(CreatedBy);“”; “”; “Status of Submitted Requested”; “This request has been Approved by the Local Team Leader & sent for Manager for approval.”; “”; [IncludeDoclink]));

@If(doc_type =“Tools”:“Software”:“Hardware”;@Success;@MailSend(@Unique(UpdatedBy);“”; “”; “Need Approval”; “This Reuest has been Approved by the Local Team Leader & need your approval.”; “”; [IncludeDoclink]));

@All; @Success;

@PostedCommand([FileSave]);

@Command([FileCloseWindow]))

Subject: @IsNotMember is not working in my Application

It would be a lot easier, if you would provide more details on what exactly happens and what you want to happen instead. Looking at your code, it appears, that it is only the first @If statement you have problems with, right?

First off, what kind of field is Approver? Is it a text field or a field of type Names? Does it really just store the common name component of the approvers? That doesn’t sound like a good idea to me. What do we have unique canonical names for, if you abbreviate them, potentially taking away uniqueness?

If this is a names field, check from the view level using the properties box what’s in the field. @UserName returns a canonical Notes name, and that is just what you want to compare the the contents of a names field.

Finally, if you want to stop the execution of a formula, use @Return().

Subject: RE: @IsNotMember is not working in my Application

Thanks Harkpabst Meliantrop for reply,

Approval Form contains below field :

1st Field. Created by : Text , Computed when composed,

                            @Name([CN];@UserName)

[Requester who creates request for Materials, hardware, software or Tools]

2nd Field. Category : Dialog List, Editable,

                           Materials, Hardware, Software, Tools

[Options for selecting the request]

3rd Field. Details if Any : Text, Editable.

[Any details]

4th Field. Date : Date/Time, Computed when composed

                    @Created.

[Requested date]

5th Field. Approver : Dialog List, Editable

                          Use Address Dialog for choices.

[Requester has to select the his/her Team Leader for approval]

6th Field. Result : Text , Computed when composed.

[This field is for to update the status of Request]

7th Field. UpDateApproved : Text , Computed when composed.

[This field is for to update the status of Request]

8th Field. mailTo : Dialog List, Editable

                       Use Address Dialog for choices

[Requester has to select the 1st Manager, if request is “Materials”]

9th Field. UpdatedBy : Dialog List, Editable

                             Use Address Dialog for choices

[Requester has to select the 2nd Manager, if request are “Hardware”, “Software”, “Tools”]

10th Button : Approve (formula)

[When Team Leader is approved, Mails has to go to 1st Manager if the request is Materials or else to 2nd Manager if the request is “Hardware”, “Software”, “Tools”]

Hope you understood the scenario.

Please help me in soling the problem.

Subject: RE: @IsNotMember is not working in my Application

As I said: Check from the view level using the properties box what’s in the field.

Since Approver is a dialog box, it stores text (not names) in abbreviated format, e.g. John Doe/Sales/MyCorp. @UserName returns the name in full canonical format, e.g. CN=John Doe/OU=Sales/O=MyCorp. You were right in using @Name to convert that. But what you need to compare is not the common name component, but the abbreviated name.

@Name([ABBREVIATE]; @UserName)

would be appropriate here. This applies, no matter if you want to stop execution of the formula, or if you want to hide the button.

One more note, though: Storing user names in text fields is surely possible and sometimes even just what you need to do (otherwise Lotus had not included the “use address dialog option” in the dialoglist field). But you should be aware of the fact, that names stored in text fields will not change, if a user is renamed (marriage, divorce, changed position, change in organizational structure, …). If the requirement for your application is to store the status quo exactly how it was at the time of approval, the text field is the right choice. If it is more important, that a name change is reflected throughout the organization including old data, it would be better suited to use a names field. This will enable the administration process to rename the field automatically, should a user name change in the future (if you enable this option via ACL). As I said, it depends on what you need.

NB: If Approver is not a multi-value field, it is not necessary to use @IsNotMember. A simple != will do.

Subject: RE: @IsNotMember is not working in my Application

Thanks Again Harkpabst Meliantrop !..

Your suggestion & information helped me lot…

Thanks

Vj

Subject: RE: @IsNotMember is not working in my Application

@If(@IsNotMember(@Name([CN]; @UserName); Approver);@Failure(@Prompt([Ok]; “NOT Signed”; “You are not listed in Authorized.”));

The problem here is that the formula uses @Failure as if it affected the flow of control, and it does not. The formula continues to execute past that point. To terminate execution of the formula, you must use @Return instead.

Subject: RE: @IsNotMember is not working in my Application

Thanks Andre Guirard , your suggestion helped.

Thanks Vj

Subject: @IsNotMember is not working in my Application

Why dont you hide the button from everyone else?

Button HideWhen: @IsNotMember(@Name([CN];@UserName);Approver)

Subject: RE: @IsNotMember is not working in my Application

Thanks Matt Smith for reply,

I already made button hide , when approved.

@If(Result = “Approved”);

Is that possible to add two condition for the same?

Subject: RE: @IsNotMember is not working in my Application

Sure.

You use the vertical bar, “|”, which means “…or…” and put the two conditions in the hide/when:

HIDE/WHEN FORMULA:

Result=“Approved” | @IsNotMember(@Name([CN];@UserName);@Name([CN];Approver))

That should work for what I understand to be your condition. Is the button on the form, or at the view level? What I am describing is on the form.

  • Matt

Subject: RE: @IsNotMember is not working in my Application

Thanks Matt again,

Yes, button on form.

I used your code.

But, Button will disappear when we create New Approval form.

[though both condition is false here]

Thanks

VJ