I am currently using the following formula to place the users name in a field.
@If(Authorised=“Pay”;@Name([CN];@UserName);“Payment is not authorised yet”)
Problem I get is if a different user is working on the form and saves it. Because the Authorised field = Pay it updates the username.
What I am looking for is a formula that will only do @Name([CN];@UserName) when a field is edited.
Any ideas.
Subject: Simple @if question
While I don’t claim this is an elegant solution:
@if(Authorised = “Pay”; @if(@thisvalue != @Name([CN]; @UserName); @thisvalue; @Name([CN]; @UserName)); “Payment is not authorised yet”)
Subject: RE: Simple @if question
Not sure if that will work as the moment Authorised is set to “Pay” the thisvalue != @Name([CN]; @UserName); condition will be true as “Payment is not authorised yet” won’t match the current username.
If the OP must use this approach then try something along the lines of:
NotAuth:=“Payment is not authorised yet”;
@if(@thisValue=NothAuth;@if(Authorised=“Pay”;@Name([CN];@username);NotAuth);@thisValue);
HTH - Rufus.
Subject: hehe…
that’s what i get for trying to code to someone else’s style.
good catch.
Subject: Simple @if question
I’d suggest looking at the bigger picture, rather than relying on computed fields (which will slow the server down, and can cause as you found unpredictable results).
I presume something is changing the value of Authorised to Pay (e.g. an action button called “Authorise for Payment”). Whatever is setting Authorised, should also be setting username field.
i.e. Make “authorisedBy” computed when composed with a value of “Payment is not authorised yet”. Then have an action button with the formula:
@setfield(“Authorised”;“Pay”);
@setfield(“AuthorisedBy”;@name([cn];@username));
or similar.
HTH - Rufus.
Subject: RE: Simple @if question
Thanks for the help guys, all sorted.