Link to home
Start Free TrialLog in
Avatar of damoncwk
damoncwk

asked on

somehow one line of code is skipped

Hi,
i include the following in the formula of a button.
rejectReason is a text field name where i have put a default value as " "
after i pressed on the button a mail is sent out
however the regHis field content is not updated, i.e. it keeps its original value.
there are no error message or error log at all.
Any cluse?
Thanks!!

@SetField("regHis"; "On " + @Text(@Now) + ", " + @Author + " wrote " + rejectReason);
@SetField("regStatus"; "On " + @Text(@Now) +",  " + @Author + " rejected.");
@MailSend(user1;user2;"";"Rejected" ;"";"Rejected.";[IncludeDoclink]);
@SetField("MAIL_SEND"; "Y");
@Command([FileSave]);
Avatar of Bozzie4
Bozzie4
Flag of Belgium image

Stop using @setfield.  It's only useful within loops (if you use R6) or within an @do structure (R5).  @setfield requires that the field already exist, and is the cause of a lot of problems, if you don't use it correctly.
Also watch out using the @author function.  It doesn't always returns the original author.  If you want it to be the name of the current user, use @username.

Try again :

FIELD regHis :=  "On " + @Text(@Now) + ", " + @name(]cn];@username) + " wrote " + rejectReason;
FIELD regStatus :=  "On " + @Text(@Now) +",  " + @name(]cn];@username) + " rejected.";
@MailSend(user1;user2;"";"Rejected" ;"";"Rejected.";[IncludeDoclink]);
FIELD MAIL_SEND :=  "Y";
@Command([FileSave])

cheers,

Tom
About @setfield : if you use R6, it should also work when the field doesn't exist yet, but it remains good practice to make sure it exists :

This is the correct way of using @setfield :

FIELD MyField := MyField;
...
@setfield("MyField";"some value");
...
Avatar of damoncwk
damoncwk

ASKER

Tom,
thanks for that.
However if I do not give any value to the rejectReason field
then the mail is still sent out.
What i am trying to achieve here is that i want to make
sure the rejectReason field is being filled with content
else the mail is not allowed to be sent.

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of Bozzie4
Bozzie4
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Try this

@SetField("regHis"; "On " + @Text(@Now) + ", " + @Author + " wrote " + rejectReason);

@SetField("regStatus"; "On " + @Text(@Now) +",  " + @Author + " rejected.");

@MailSend(user1;user2;"";"Rejected" ;"";"Rejected.";[IncludeDoclink]);

@SetField("MAIL_SEND"; "Y");

@PostedCommand([FileSave]);

~Hemanth