Using FIELD in a @If Statement

I'd like to set a value of a field in a document if the user selects yes from a prompt.

Here is the code I have in an action button:

answer := @Prompt([YesNo]; "Submit?"; "Are you sure you want to submit this contract for PM Approval?");

@If(
  answer = 1;
  @Do(
    FIELD := "Pending PM Approval";
    @PostedCommand( [FileSave] );
    @PostedCommand( [FileCloseWindow] );
  );
  "");

However, I'm getting a "missing semicolon" error and the word FIELD is red.  What am I not understanding?

Thanks.
LVL 13
cLFlaVAAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

p_parthaCommented:
Where is the field name?

partha
0
Sjef BosmanGroupware ConsultantCommented:
How about
    @SetField("Thefieldnameyourforgottomention"; "Pending PM Approval");
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
p_parthaCommented:
THis is the correct syntax:

answer := @Prompt([YesNo]; "Submit?"; "Are you sure you want to submit this contract for PM Approval?");

@If(
 answer = 1;
 @Do(
   FIELD fieldname:= "Pending PM Approval";
   @PostedCommand( [FileSave] );
   @PostedCommand( [FileCloseWindow] )
 );
 "");
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

p_parthaCommented:
Sjeffffffffffffffffffffffffffffffffffffffffffffffffff my bro.. no stealing :(((((

Partha
0
cLFlaVAAuthor Commented:
Yeah, sorry, I had this:

answer := @Prompt([YesNo]; "Submit?"; "Are you sure you want to submit this contract for PM Approval?");

@If(
 answer = 1;
 @Do(
   FIELD ContractStatus := "Pending PM Approval";
   @PostedCommand( [FileSave] );
   @PostedCommand( [FileCloseWindow] )
 );
 "");

And it's giving me that error.
0
cLFlaVAAuthor Commented:
Won't setfield only work with a field in edit mode?  Or is that something else?
0
p_parthaCommented:
The code you pasted works fine for me... IN the earlier code you had a semicolon which is missing now after fileclosewindow...

Partha
0
Sjef BosmanGroupware ConsultantCommented:
I ain't stealin' bro! :(

I just happen to know (from the Help db) that it says: "You cannot use the FIELD reserved word within an @function". That's all.

Or am I stealing just a teeny weeny... ?
0
cLFlaVAAuthor Commented:
I copied your code, p_partha, exactly.  I then changed the field name.  This is what I have right now:

answer := @Prompt([YesNo]; "Submit?"; "Are you sure you want to submit this contract for PM Approval?");

@If(
 answer = 1;
 @Do(
   FIELD ContractStatus:= "Pending PM Approval";
   @PostedCommand( [FileSave] );
   @PostedCommand( [FileCloseWindow] )
 );
 "");

Gives the error.

Now i'll try setfield.
0
p_parthaCommented:
The code which cLFlava works for me. It sets the value of contractstatus and saves & closes the window

partha
0
p_parthaCommented:
Wow it works in R6 and not in R5.. Very strange though, then adopt Sjef's suggestion:

 answer := @Prompt([YesNo]; "Submit?"; "Are you sure you want to submit this contract for PM Approval?");
field contractstatus:=Contractstatus;
@If(
answer = 1;
@Do(
  @setfield("ContractStatus";"Pending PM Approval");
  @PostedCommand( [FileSave] );
  @PostedCommand( [FileCloseWindow] )
);
"");
0
cLFlaVAAuthor Commented:
Yup, it works now.

What do you guys want me to do with the points?
Split?


Thanks again - I didn't forget about my other question - I'll get back to it in a bit.
0
p_parthaCommented:
if it is not a prob Give 70% to sjef and 30% to me...

Partha
0
HemanthaKumarCommented:
CL what is your notes version ?

You cannot use FIELD assignment operator in statements in R5.. But R6 allows this.

If you are using R5.. as Partha mentioned use @SetField.. But you have to define the FIELD ContractStatus := ContractStatus at the top  of the code.

~Hemanth
0
cLFlaVAAuthor Commented:
Yeah, I am using R5.
Using @SetField worked.  The field already exists, so I assume I don't need the initial FIELD statement...
0
cLFlaVAAuthor Commented:
p_,

that's fine with me...
0
cLFlaVAAuthor Commented:
Raised the points, cause they're free anyway.
Then gave 70/30.
0
Sjef BosmanGroupware ConsultantCommented:
You're all too kind! Getting emotional...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.