[Last Call] Learn how to a build a cloud-first strategyRegister Now

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

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.
0
cLFlaVA
Asked:
cLFlaVA
  • 7
  • 7
  • 3
  • +1
2 Solutions
 
p_parthaCommented:
Where is the field name?

partha
0
 
Sjef BosmanGroupware ConsultantCommented:
How about
    @SetField("Thefieldnameyourforgottomention"; "Pending PM Approval");
0
 
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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