[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 258
  • Last Modified:

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]);
0
damoncwk
Asked:
damoncwk
  • 3
1 Solution
 
Bozzie4Commented:
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
 
Bozzie4Commented:
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
 
damoncwkAuthor Commented:
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
 
Bozzie4Commented:
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
 
HemanthaKumarCommented:
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now