Solved

somehow one line of code is skipped

Posted on 2004-04-28
5
245 Views
Last Modified: 2013-12-18
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]);
0
Comment
Question by:damoncwk
  • 3
5 Comments
 
LVL 15

Expert Comment

by:Bozzie4
ID: 10937374
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
0
 
LVL 15

Expert Comment

by:Bozzie4
ID: 10937381
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");
...
0
 

Author Comment

by:damoncwk
ID: 10937467
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!
0
 
LVL 15

Accepted Solution

by:
Bozzie4 earned 125 total points
ID: 10938674
Aha.  Add this first line.  This will stop executiong of the formula.

@if( rejectReason = ""; @return(@prompt([ok];"Warning";"You must enter a value for rejectReason")); "") ;
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])

Also use the Input Validation formula for rejectReason (Something should be a status or something :  eg. status = "rejected" ):

@if( Something & @trim(rejectReason) = ""; @failure(" please give a reason" ) ; @success )
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 10938887
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
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now